2

I have a system that inputs multiple images via a backend script ... i want to be able to echo out the images into a list on the frontend so i can manipulate them.

Im not exactly sure how i would do this using a loop.

In my PHP im viewing the contents of the array using the following:

<?php print_r($node->rotator['und']); ?>

When it prints out, its giving me the following information

Array (
    [0] => Array ( [fid] => 4 [alt] => [title] => [uid] => 1 [filename] => fredmanhhh.jpeg [uri] => public://fredmahjk.jpeg [filemime] => image/jpeg [filesize] => 108646 [status] => 1 [timestamp] => 1311781185 [rdf_mapping] => Array ( ) ) 
    [1] => Array ( [fid] => 6 [alt] => [title] => [uid] => 1 [filename] => 92_mr_t_snickers1.jpeg [uri] => public://92_mr_t_snickers1_1.jpeg [filemime] => image/jpeg [filesize] => 475757 [status] => 1 [timestamp] => 1311785879 [rdf_mapping] => Array ( ) ) 
)

What i need to do with a loop is extract the [filename] and add that inside the list tag for each image thats been uploaded.

If anyone could help me, that would be grand.

Cheers

2 Answers 2

2
foreach($node->rotator['und'] as $row){
    echo '<li><img src="' . $row['filename'] . '"/></li>';
}
Sign up to request clarification or add additional context in comments.

Comments

0

Well, basically what you're trying to do is loop through all of the arrays and then output them:

foreach( $node->rotator['und'] as $und ) 
   echo '<li><img src="' . $und['filename'] . '"/></li>';

To store them for later at the same time:

$undFiles = array();

foreach( $node->rotator['und'] as $und ) 
{
   $undFiles[] = $und['filename'];
   echo '<li><img src="' . $und['filename'] . '"/></li>';
}

Comments

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.