array_keys() error...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I've searched all over and can't find an explanation for this, but I am

I am getting a warning generated by array_keys when I pass it an array with
just one element... is this expected?

For example:

$temp_arr = array('flickr reidrolls photostream jonathan pierce
2296319775_a96b3c89d7.jpg' => 3);
$keys = array_keys($temp_arr);

Generates the error:

Warning: array_keys() [function.array-keys]: The first argument should be an

Even though print_r($temp_arr); returns:

Array ( [flickr reidrolls photostream jonathan pierce
2296319775_a96b3c89d7.jpg] => 3)

When $temp_arr, which is dynamically generated based on user input, has more
than one element, no warning is generated.

Any ideas?  I suppose I could check for just one entry and avoid passing to
arra_keys, but that seems like a workaround for something the function
SHOULD do (if I am using it correctly of course).



Re: array_keys() error...

GS wrote:
Quoted text here. Click to load it

Double check your code because this:

$temp_arr = array("flickr reidrolls photostream jonathan pierce
$keys = array_keys($temp_arr);

works for me.

Maybe your not passing the array due to spelling.


Re: array_keys() error...

Quoted text here. Click to load it

me too


Site Timeline