I have an array:
"city": [
{
"kind": "qpxexpress#cityData",
"code": "CHI",
"name": "Chicago"
},
{
"kind": "qpxexpress#cityData",
"code": "LAX",
"name": "Los Angeles"
},
{
"kind": "qpxexpress#cityData",
"code": "YMQ",
"name": "Montreal"
},
{
"kind": "qpxexpress#cityData",
"code": "YOW",
"name": "Ottawa"
},
{
"kind": "qpxexpress#cityData",
"code": "YVR",
"name": "Vancouver"
}
]
It's complete path is: array->trips->data->city What I want to do is get the "name" from the array, if the "code" matches the code that is provided:
function getCity($string, $array) {
foreach ($array as $place) {
if (strstr($string, $place)) { // mine version
echo "Match found";
return true;
}
}
echo "Not found!";
return false;
}
This is all I have gotten. I have no idea how to continue.
return true,return $place['name']