Saturday, July 14, 2012

PHP: get keys from array

Use array_keys() method:

$array = array("color" => "blue", "size"  => "small");
print_r(array_keys($array)); /* prints the following:
Array
(
    [0] => color
    [1] => size
)*/

Reference:
http://php.net/manual/en/function.array-keys.php


No comments: