php extract all objects from an array if value equals to a variable -


i have array of objects :

array (size=13)   0 =>      array (size=7)       'id' => string '62' (length=2)       'firstname' => string 'alio' (length=24)       'lastname' => string 'djam' (length=7)       'city' => string 'paris' (length=8)   1 =>      array (size=7)       'id' => string '2' (length=1)       'firstname' => string 'jack' (length=7)       'lastname' => string 'jacky' (length=6)       'city' => string 'berlin' (length=8)   ... 

i need extract objects city equals variable (berlin, paris, ...).

$city = 'berlin'; $found = []; foreach($data $row){    if($row['city'] == $city){        $found[] = $row;    } } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -