![]() |
Returning pointer to 1st element in associative array
Hi folks,
I have an associative array. After some processing, the pointer is now past the last element. How can I move the pointer back up to the first element without recalling the original query? I searched for an answer, but most of the examples show how to "get" the first array. But I simply want to move the pointer back to the first array element. Thanks! Dave |
would reset be of any use to you?
|
Quote:
Thanks!! Code:
$c_pettype = 'horse' ; // From user.================== ELEMENT 1 Array ( [petpk] => 1 [petname] => unicorn [pettype] => horse [petdesc] => spiral horn centered on forehead [price] => 999.99 ) using RESET() here...SHOULD BE ELEMENT 1 AGAIN Array ( [petpk] => 2 [petname] => pegasus [pettype] => horse [petdesc] => flying: wings sprouting from back [price] => 999.99 ) |
I'm not sure but the ID of the array values may not change, so it looks like you are printing out the first value's data (array).
|
You could use
mysql_data_seek like below. Although it seems peculiar to me how you're using this.php Code:
|
Wildhoney --
Thanks very much. That was very helpful. In all my Googling, I did not come across a mention of "mysql_data_seek." Wonder why? Anyway, I read more about the mysql_data_seek function on php.net, and the user posts were very interesting. Here is Kenneth Nash's interesting UDF from that discussion: Code:
/*here is a nice function for converting |
| All times are GMT. The time now is 09:00 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0