note 51558 added to control-structures.for

From: Date: Mon, 04 Apr 2005 06:47:07 +0000
Subject: note 51558 added to control-structures.for
Groups: php.notes 
Request: Send a blank email to php-notes+get-87415@lists.php.net to get a copy of this message
spent some time trying to work this out, and still couldnt resolve it. $s is a multidimensional array, where the second level is associative and numeric array from mysql... i dont have a choice in the second level array type... the following code crashed the sever process <? for ( $x=0; $x<count($s); $x++ ) { foreach ($s[$x] as $key => $val) { echo '<br />'.$key.' - '.$val; } }?> instead i had to do: <? for ( $x=0; $x<count($s)-1; $x++ ) { for ( $y=0; $y<(count($s[$x])/2); $y++ ) { echo '<br />'.$y.' - '.$s[$x][$y]; } }?> i can only assume that the pointers are bugging up somewhere in the first example. hope this saves someone some time trying to figure out what may be wrong with their syntax ---- Manual Page -- http://www.php.net/manual/en/control-structures.for.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51558 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51558&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51558&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51558&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51558&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51558&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51558&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87415) next »