Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- array_keys() error...
March 25, 2009, 12:42 am
rate this thread
I am getting a warning generated by array_keys when I pass it an array with
just one element... is this expected?
$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).