Good day. The cost of the task is to choose from the array id by name $data = "Калуга" the array itself:
$getAccount = [groups] => Array ( [0] => Array ( [id] => 48699 [name] => Калуга ) [1] => Array ( [id] => 48702 [name] => Краснодар2 ) [2] => Array ( [id] => 48705 [name] => Ростов-на -Дону ) [3] => Array ( [id] => 48708 [name] => Архангельск ) [4] => Array ( [id] => 48711 [name] => Пермь ) [5] => Array ( [id] => 48714 [name] => Белгород ) ) my example doesn't work:
$get = array(); foreach ($getAccount["groups"] as $key => $val) { if($get[$key]["name"] == $data){ return $get[$key]["id"] = $val; } } echo '<pre>'.print_r($get, true).'</pre>'; die(); I would appreciate if you point to an error