in Education by
I try to print images with a for loop but the images dont load. <?php $imagenes = array('1.png', '2.jpg', '3.png', '4.jpg','IMG_0105.JPG'); ?>
<?php for ($i=0; $i < 4; $i++) { echo '<img src = \"$imagenes[$i]\" width = \'100px\' height = \'100px\';>'; } ?>
The images are in the same folder as the .php file JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Edit: Added additional solutions based on answer from @nik This will never work because variables are not evaluated inside of single quoted strings. Make sure that your use a string inside double quotes. Or use string concatenation to build the HTML tag. Also, you image tag has a semicolon inside of it that might break the tag. So you can do this ... echo "image"; or echo "image"; or image" width="100px" height="100px"> or image" width="100px" height="100px">

Related questions

0 votes
    I try to print images with a for loop but the images dont load. The images are in the same ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    NOTE: I am not set on using VI, it is just the first thing that came to mind that might be able to do what I need ... there an automated way I can take the text: and change it to:...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I need to take the users input from the select box for Allergen1 once an option is selected and the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I want to show in an alert a french sentence containing accentuated letters such as "é" and "à". ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How can I access an array/object? (6 answers) Closed 3 years ago. i have a ... print_r($_POST); i can see all the variable in the right way...
asked May 22, 2022 in Education by JackTerrance
0 votes
    This question already has answers here: How can I access an array/object? (6 answers) Closed 3 years ago. i have a ... print_r($_POST); i can see all the variable in the right way...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Write a program to store 10 names in an array. Arrange these in alphabetical orderby sorting. Print the sorted list. ... , LUCY, etc. Select the correct answer from above options...
asked Dec 12, 2021 in Education by JackTerrance
0 votes
    Write a program to generate first 20 terms of Fibonacci series and store them in single dimension array. Display ... from the array Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Rewrite the following loop using for loop: int i=0; while (i...
asked Dec 22, 2021 in Education by JackTerrance
...