Is it possible to put an img src inside an array? I have this project on html/css/javascript and php and so far I’ve created a website where you can buy cars online. Now I want to create a page where I list the cars, models and the prices. I’ve thought about creating an array, that contains other arrays that are basically the cars (photo, type and price) and then put them in a database and then the user can list the cars based on the type of the car or the price (maybe with a slider). But idk if I can put an img src inside an array so is it possible to do it?
(PS, I haven’t learned about node yet) Sorry if this isn’t enough info.
Advertisement
Answer
You can create array of object.
[{ photo : "<image url>", type : "<type>", price : 5000 }, { photo : "<image1 url>", type : "<type>", price : 4000 }, { photo : "<image2 url>", type : "<type>", price : 7000 }]
Then you can iterate over each object and display the info in HTML page.
Thanks