I have a multidimensional array in PHP that I am trying to search for a specific value (url
) and then retrieve an associated value (value
). I also need to divert to an else if it is not found.
array(2) {
[0]=> array(2) {
["url"]=> string(7) "fareham"
["value"]=> string(7) "Fareham"
}
[1]=> array(2) {
["url"]=> string(11) "southampton"
["value"]=> string(11) "Southampton"
}
}
I have been experimenting with array_key_exists and isset to check it's set and just coming up null! Any pointers for best practice to do this would be much apreciated.