i'm trying refer primary phone number in array
"phone":[{"label":"fax","value":"234-345-5678","primary":false},{"label":"main","value":"456-234-2345","primary":false},{"label":"main","value":"456-456-4567","primary":true}] i'm using following php:
"person_phone" => $phonenumbers['phone'][2]['value']; but primary phone may not 3rd item within an, there way evaluate "primary":true of array element before deciding refer it.
you can't single "simple" array reference. php's arrays "paths" aren't searchable if had xpath or something. you'd have loop on array find "primary" record, access number once found:
foreach($records $phone) { if ($phone['primary']) { return $phone['value']; } }
Comments
Post a Comment