How to get the Cat by using the value Nap
in array
["Dog" => "Bite", "Cat" => "Nap"]
and i want to get Cat
using value Nap
How to get the Cat by using the value Nap
in array
["Dog" => "Bite", "Cat" => "Nap"]
and i want to get Cat
using value Nap
What is not clear in your question is if you already know the entry is the last entry, or if you're searching for a value that is somewhere in your array.
If you have PHP 7.3, and you know it's the last entry, you can use array_key_last()
(see http://php.net/manual/en/function.array-key-last.php )
$key = array_search('Nap', $array);
(as mentionned by @Sanu0786 )