Re: [PHP] While on array?
> ie - i have: > while($myrow=mysql_fetch_array($result)) { etc... > > But i want the loop to run with an array i created earlier ($anotherarray = > [key1] => value1, [key2] => value2). > use foreach($anotherarray as $key => $value) { . A Nawroth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] While on array?
You should probably take a look at each() for that... The functionality is not the same but it's the only answer I can think of for your question (i.e. mysql_fetch_row() _returns_ a key-value array while each() _walks_ a key-value array). Bogdan Daniel Alsén wrote: > Hi, > > i am fiddling with a script and need to change a while-loop from running on > mysql_fetch_array to a "normal" array? > > ie - i have: > while($myrow=mysql_fetch_array($result)) { etc... > > But i want the loop to run with an array i created earlier ($anotherarray = > [key1] => value1, [key2] => value2). > > How would i do that? Does the loop behave the same way - running until the > array is out of data? > > Thanks! > # Daniel Alsén| www.mindbash.com # > # [EMAIL PROTECTED] | +46 704 86 14 92 # > # ICQ: 63006462 | +46 8 694 82 22 # > # PGP: http://www.mindbash.com/pgp/ # > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] While on array?
Hi, i am fiddling with a script and need to change a while-loop from running on mysql_fetch_array to a "normal" array? ie - i have: while($myrow=mysql_fetch_array($result)) { etc... But i want the loop to run with an array i created earlier ($anotherarray = [key1] => value1, [key2] => value2). How would i do that? Does the loop behave the same way - running until the array is out of data? Thanks! # Daniel Alsén| www.mindbash.com # # [EMAIL PROTECTED] | +46 704 86 14 92 # # ICQ: 63006462 | +46 8 694 82 22 # # PGP: http://www.mindbash.com/pgp/ # -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]