array_keys
Posted: Mon Sep 10, 2007 11:07 am
I am trying to access the keys of an array, using the array_keys function.
The problem is that the array returned by the array_keys function includes as elements a numeric index for each key, as well as the keys themselves, so that the elements I am interested in are every (2n+1)th element.
I seem to recall there is some parameter I need to set to change this behaviour but trawling through documentation and forums leaves me none the wiser.
I want array_keys to give me
[0] => key1
[1] => key2
[2] => .... etc ....
but at the moment I am getting
[0] => 0
[1] => key1
[2] => 1
[3] => key2
[4] => 2
[5] => .... etc ....
can anyone help?
The problem is that the array returned by the array_keys function includes as elements a numeric index for each key, as well as the keys themselves, so that the elements I am interested in are every (2n+1)th element.
I seem to recall there is some parameter I need to set to change this behaviour but trawling through documentation and forums leaves me none the wiser.
I want array_keys to give me
[0] => key1
[1] => key2
[2] => .... etc ....
but at the moment I am getting
[0] => 0
[1] => key1
[2] => 1
[3] => key2
[4] => 2
[5] => .... etc ....
can anyone help?