I have an array in PHP structured like below. If I return the 'StateID' from a REST call, how can I use the ID to get the abbreviation and state name for that ID? For example an ID of '1' would return an abbreviation of Name = Alabama and Abbreviation = AL..
Array:
array(1) { ["StateList"]=> array(50)
{ [0]=> array(3)
{ ["StateID"]=> int(1) ["Name"]=> string(7) "Alabama" ["Abbreviation"]=> string(2) "AL" }
[1]=> array(3)
{ ["StateID"]=> int(2) ["Name"]=> string(6) "Alaska" ["Abbreviation"]=> string(2) "AK" }....
echo array_reduce($arr, function ($abbr, $state) { return $abbr ?: ($state['StateID'] == 1 ? $state['Abbreviation'] : null); })- just because.