jwk811 Posted February 20, 2007 Share Posted February 20, 2007 i forgot how to do this.. i return an array from a function, out can i get each part of that array out so i can use each value? Link to comment https://forums.phpfreaks.com/topic/39325-return-array/ Share on other sites More sharing options...
mbtaylor Posted February 20, 2007 Share Posted February 20, 2007 foreach ($array as $var => $value) { print ("$var = $value"); } // or print_r ($array); //or print ($array[0]); //or $max = count ($array); for ($i=0;$i<$max;$i++) { print ($array[$i]."<br />"); } Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189617 Share on other sites More sharing options...
utexas_pjm Posted February 20, 2007 Share Posted February 20, 2007 If the number of array elements are known you can use: http://us2.php.net/list Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189665 Share on other sites More sharing options...
.josh Posted February 20, 2007 Share Posted February 20, 2007 // or $x = 0; while ($array[$x]) { echo $array[$x]; $x++; } // or...LoL Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189667 Share on other sites More sharing options...
mbtaylor Posted February 20, 2007 Share Posted February 20, 2007 Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189668 Share on other sites More sharing options...
lando Posted February 20, 2007 Share Posted February 20, 2007 You could also use extract($array); There are some issues with using it but it is worth checking into because of its simplicity. http://www.php.net/manual/en/function.extract.php Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189681 Share on other sites More sharing options...
Barand Posted February 20, 2007 Share Posted February 20, 2007 // or $x = 0; while ($array[$x]) { echo $array[$x]; $x++; } // or...LoL CV, If error_reporting's "E_ALL" Your code is going to fall You should use "isset()" And then you won't get Annoying notices at all $x = 0; while (isset($array[$x])) { echo $array[$x]; $x++; } Link to comment https://forums.phpfreaks.com/topic/39325-return-array/#findComment-189861 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.