Re: Equivelant to mysql_fetch_row for normal array

From: Date: Thu, 22 Jun 2006 16:41:43 +0000
Subject: Re: Equivelant to mysql_fetch_row for normal array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238517@lists.php.net to get a copy of this message
Dave M G wrote: > PHP List, > > Very frequently I use mysql_fetch_row in a while statement to > > while($variable = mysql_fetch_row($mysqlResult)){ > echo $variable[text1]; > echo $variable[text2]; another thing. $variable[text2] is bad because you very likely don't have a constant in your code named 'text2' - you should be using string keys (if you had error_reporting set to include E_NOTICE errors you would see notices output regarding non-existent constants... do this instead: echo $variable['text1']; echo $variable['text2']; > } > > Pretty standard. > > But what do I do when I want to do the same kind of while loop not with > a MySQL result, but with just a regular array? > > while (variable = ????($array)){ > echo $variable[text1]; > echo $variable[text2]; > } > > I've been up and down the manual, and looked at foreach statements and > functions like each(), but I can't seem to zero in on what I need. > > Can anyone let me know what it is I'm missing? > > Thank you for any advice. > > -- > Dave M G >

« previous php.general (#238517) next »