Re: Determine which are user defined keys?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, January 11, 2008 7:12 am, Christoph Boget wrote:
> Given the following array:
>
> <?php
>   $myArr = array( 'joe' => 'bob', "0" => 'briggs', 'whatever',
> 'whereever');
>   echo '<pre>' . print_r( $myArr, TRUE ) . '</pre>';
> ?>
>
> Array
> (
>  [joe] => bob
>  [0] => briggs
>  [1] => whatever
>  [2] => whereever
> )
>
> "joe" and "0" are keys that I created whereas the key "1" and "2" are
> keys assigned by PHP when the array was created.  When iterating
> through an array, is there a way to determine which were generated by
> PHP?  I can't rely on whether or not the key is an integer because
> it's quite possible that such a key was user generated.  I've gone
> through the docs and based on what I've read, I don't think something
> like this is possible but I'm hoping that's not the case.

I doubt that even down in the guts of PHP there's any record of which
kind of key it was, so I doubt that you can do that without hacking
PHP scource in a big way...

WHY would you want to do this anyway?

Give us the Big Picture, and maybe you'll get some ideas for another
approach.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux