Re: re: array question
| From: | Scott | Date: | Wed, 19 Sep 2001 02:58:20 +0000 |
| Subject: | Re: re: array question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-67782@lists.php.net to get a copy of this message | ||
That works, thank you, but it prints at the top of my page, is there
a way to store that array into a single variable?
At 07:43 PM 9/18/2001 -0700, Jason Bell wrote:
or, assuming PHP4 is in use, you can do it a little cleaner, and use a foreach loop: foreach ($array as $value) {print $value;} if you wanted the key names, as well as the value, you could use this: foreach ($array as $key => $value) {print "$key of \$array = $value";} ----- Original Message ----- From: "Jack Dempsey" <dempsejn@georgetown.edu> To: "Scott" <sparks@magpage.com>; <php-general@lists.php.net> Sent: Tuesday, September 18, 2001 7:29 PM Subject: RE: [PHP] re: array question perhaps i'm misunderstanding you, but why not use a for loop? for($i=0;$i<count($array)-1;$i++){ echo $array[$i]; } jack -----Original Message----- From: Scott [mailto:sparks@magpage.com] Sent: Tuesday, September 18, 2001 10:11 PM To: php-general@lists.php.net Subject: [PHP] re: array question Oh, that works wonders and for the first time in 24 hours I am smiling! One more thing to make it complete. Is there a way to loop through the display of that array? In other words, I now have an array called $new_data and can call each element in the array by doing $new_data[0], etc, but I need to loop through everything in the array to display the navigation. At 08:54 PM 9/18/2001 -0400, you wrote: so then that last line in the loop should be $new_data[] = $ln; During the loop, everytime it comes to this line, $ln is added to the array new_data. Eventually, you will be >able to call on the array elements by $new_data[0], $new_data[1], etc.... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net