Re: [PHP-DEV] Funny array function

2012-10-01 Thread Chris van Dam
Hi Kuldeep, Why would you want to do this, it seems to me there is more code than the regular array access method. Kind regards, Chris van Dam Op 30-09-12 13:50 schreef kuldeep dhaka : >hello guys, >this is my first time, if thing mail is at wrong place please forward it >the right place. >whi

Re: [PHP-DEV] Funny array function

2012-09-30 Thread Eitan Mosenkis
Those look good except that you're using isset($ar[$key]) when you should be using array_key_exists($key, $ar). If the value you were trying to set is set to null, your function will erroneously return false instead of null (since it isn't 'set', but the key does in fact exist) On Sun, Sep 30, 201

Re: [PHP-DEV] Funny array function

2012-09-30 Thread Andrew Faulds
On 30/09/12 13:05, kuldeep dhaka wrote: i m extending the wordpress internal widget input api to simplify things, so for that i wanted a function that perform drill. i have considered other options but they wont be effecient, if a php internal function is build it would be just a [] similar one,

Re: [PHP-DEV] Funny array function

2012-09-30 Thread kuldeep dhaka
i m extending the wordpress internal widget input api to simplify things, so for that i wanted a function that perform drill. i have considered other options but they wont be effecient, if a php internal function is build it would be just a [] similar one, and most effecient because while recursi

Re: [PHP-DEV] Funny array function

2012-09-30 Thread Ryan McCue
kuldeep dhaka wrote: > /* > i was thinking if is their any function that can do the above work like > */ > echo array_drill($array, array("school","class","roll_number","name")); The following should work: function array_drill($array, $keys) { while (($key = array_shift($keys)) !== null)

Re: [PHP-DEV] Funny array function

2012-09-30 Thread Anthony Ferrara
Yes, it's fairly trivial to write a function for this. I wrote a pair of them in about 2 minutes: http://codepad.viper-7.com/rqVlqL On Sun, Sep 30, 2012 at 7:56 AM, Charlie Somerville < char...@charliesomerville.com> wrote: > I'm struggling to imagine how such a function would be useful consid

Re: [PHP-DEV] Funny array function

2012-09-30 Thread Charlie Somerville
I'm struggling to imagine how such a function would be useful considering you can already use [] to index arrays. If you have a variable 'depth' you need to drill down to, then writing a function to do that is also fairly trivial. On Sunday, 30 September 2012 at 9:50 PM, kuldeep dhaka wrote: