John Davidson

php - I've got a javascript array and want to call images by name

0 comments
Message:


I am an object oriented programming dev who's getting extremely frustrated with web languages.
Here's the thing...
I have an array in javascript that looks somewhat like this after a split:


imgArr [1, 6, 0, 2.......]

This is not a static array but something I am reading from a variable source, meaning sometimes the array will have a different number of entries.


My goal is simple, I want to add as many image sources as array entries are and replace the image source name by these numbers in the array.


My usual approach to this would be to do something like:


<img src=("img/userpics/" + ${imgArr{i}} + ".png");

inside an incremental for, but this doesn't seem possible or if it is, I really don't know how nor can I find how to do it.


How can I proceed? Can anybody please help this poor web dev illiterate?



My Answer:
PHP is a popular server-side scripting language that is used to create dynamic web pages. It is often used in conjunction with HTML to add functionality to websites, such as processing form data, interacting with databases, and generating dynamic content. PHP code is embedded within HTML documents and is executed on the server before the page is sent to the client's web browser.

Rate this post

4 of 5 based on 1639 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us