My $_SESSION stores array in the format below. All of productId value are unique. I want to get array key using a productId.
Array
(
[0] => Array
(
[productId] => 3
[productQuantity] => 1
)
[1] => Array
(
[productId] => 4
[productQuantity] => 1
)
[2] => Array
(
[productId] => 5
[productQuantity] => 1
)
)
I have tried array_search but its not working. I actually saw a similar question, but the answer was left untold. This is the code i tried but its not displaying anything:
$key = array_search(3,$_SESSION['cart']);
echo $key;