bilis_money Posted July 13, 2006 Share Posted July 13, 2006 guys?ok, let say i have these array structure:[code]Array( [s_id] => 91 [s_photo_filename] => logo03.gif [s_tmp_name] => [s_type] => image/gif [s_size] => 4612 [s_path] => [s_date] => 2006-06-25 [s_comments] => TEsting, testing [s_photo_category] => )[/code]now i know that the keys of the array are in string and not in intergers.how would you loop and move the array pointer from 0 to 9?i know these codes below are not possible because the array keys is in strings.[code] while($i < 9) { $result = $_session[$i]; //this will not work echo "$i: ". $result. "<br>"; $i++; }[/code]now what's your way of solving this?thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/14534-how-would-you-print-this-array-values/ Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 I think this will do it:[code]$i=0;foreach($arrayName as $key=>$value) { $result = $_session[$key]; //this will not work echo "$i: ". $result. "<br>"; $i++;$i++;}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/14534-how-would-you-print-this-array-values/#findComment-57621 Share on other sites More sharing options...
bilis_money Posted July 13, 2006 Author Share Posted July 13, 2006 ok thanks i'll try to understand foreach again.i have just forgot the essence of it.thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/14534-how-would-you-print-this-array-values/#findComment-57648 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.