Jump to content

foreach not display array content correctly


real_illusions

Recommended Posts

Hi all,I've got some code that, in theory, should work.

$altimages = get_image_alt($file);echo "<ul>";foreach ($altimages as $key => $value) {	echo "<li>". $key . "; " . $value ."</li>";	}echo "</ul>";

I've left off the function (get_image_alt), as I know that works. Echoing out the Array (with print_r) displays an associative array. Now, when I run the above code, I get this: * 0; Array * 1; 98Why is it doing that and not displaying the content of the array?

Link to comment
Share on other sites

echo wont display the array members. probably your $altimages[0] holding another array. var_dump it. it will show you what it is holding to be sure.

Link to comment
Share on other sites

what's the output of print_r($altimages)?edit: or var_dump it as birbal suggested. you probably have to dig deeper into the array as birbal also said.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...