Re: [PHP] problem with function array_* that preserved the key

2001-11-14 Thread Papp Gyozo

I've not found the original post, I've just figured out from what Stig underlined. 

what about traversing an array like that:

foreach (array_keys($arrC) as $key) {
$arrC[$key]; // do some stuff with array values...
}

This statement always traverse the array with its keys, no matter what those keys
are.

hth

- Original Message - 
From: "Stig Venaas" <[EMAIL PROTECTED]>
To: "Reuben D Budiardja" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Wednesday, November 14, 2001 9:49 AM
Subject: Re: [PHP] problem with function array_* that preserved the key


> On Sat, Nov 03, 2001 at 03:54:23PM -0500, Reuben D Budiardja wrote:
> > since the key are preserved, arrC is no longer indexed from 0. Well, in most 
> > cases I don't care about the key if it's just indexed array. But since the 
> > key I preserved, I can no longer do
> > 
> > for($i=0; $i >   echo $arrC[$i];
> > 
> > if it happens that the returned indedex in array C 19, 20,25, for example. 
> > Any workaround?
> 
> There are many other ways you could traverse the array, but I think
> array_values() does what you want.
> 
> Stig
> 
> -- 
> 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] problem with function array_* that preserved the key

2001-11-14 Thread Stig Venaas

On Sat, Nov 03, 2001 at 03:54:23PM -0500, Reuben D Budiardja wrote:
> since the key are preserved, arrC is no longer indexed from 0. Well, in most 
> cases I don't care about the key if it's just indexed array. But since the 
> key I preserved, I can no longer do
> 
> for($i=0; $i   echo $arrC[$i];
> 
> if it happens that the returned indedex in array C 19, 20,25, for example. 
> Any workaround?

There are many other ways you could traverse the array, but I think
array_values() does what you want.

Stig

-- 
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]