View Single Post
Old 08-18-2009, 08:37 PM   PM User | #1
seco
Regular Coder

 
seco's Avatar
 
Join Date: Nov 2008
Location: Oregon
Posts: 682
Thanks: 5
Thanked 79 Times in 77 Posts
seco has a little shameless behaviour in the past
while to foreach array

Just a quick and simple snippet, im sure most of you know this one but for those who dont, enjoy.

PHP Code:
<?php
     
while($row mysql_fetch_array$result )) {
        
$new=$row['fieldname'];
        
$new_array[] = $new
     } 
      
     foreach(
$new_array as $key => $value) {
        echo 
$key" - " $value "<br />";
     }
?>
This will print out something similar to:

0 - result0
1 - result1
2 - result2
3 - result3
4 - result4

etc....
5 - result5
seco is offline   Reply With Quote