Tom Cake Tom Cake - 3 months ago 10
PHP Question

How to get array name from associative array

I have this associative array:

Array ( [42] => Array ( [quantity] => 1 ) [43] => Array ( [quantity] => 3 ) )


I need to get those 42 and 43 into string or integer (it is my order_id).

Do you know how?

Answer

Just use the array_keys function (https://secure.php.net/manual/en/function.array-keys.php). It returns the keys of an array.