1

I have a script to upload multiple images. After upload this is the logic:

if(isset($_POST['submit'])){

    $value = $_POST['uploaded_image_name'];
    //print_r(array_values ($value));
    echo "</br>";
    $juntos = implode("-",$value); // joga no db tipo separados por - 1591455823.jpg-1591455824.jpg
    echo $juntos;
    print_r (explode("-",$juntos)); //volta o array 
}

This code returns to me something like:

1591456130.jpg-1591456132.jpg 

and the explode

print_r (explode("-",$juntos));

returns:

Array ( [0] => 1591456130.jpg [1] => 1591456132.jpg )

The question is how to get these array values use them as the source for HTML images? Something like this:

echo '<img src="1591456130.jpg">';
echo '<img src="1591456132.jpg">';
4
  • I did not understand what exactly you need Commented Jun 6, 2020 at 15:16
  • hint: for loop/foreach Commented Jun 6, 2020 at 15:17
  • can you provide more clarity ? you mention that you are uploading images so I should see the $_FILES variable. Commented Jun 6, 2020 at 15:18
  • Get this Array ( [0] => 1591456130.jpg [1] => 1591456132.jpg ) and show as each image on html Commented Jun 6, 2020 at 15:18

1 Answer 1

2

To iterate the array and print the contents as a list in the browser.

foreach($value as $img){
     print "<img src='$img' >";
}
Sign up to request clarification or add additional context in comments.

2 Comments

does this answered your question ?
I think so, just let me implement and see how it goes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.