php - Check if value if exists and return the object in multidimensional array -


i need check if value exists in array , once exists need object.

array (     [0] => array         (             [_id] => array                 (                     [purok] => test                     [year] => 2017                     [options] => below-1                 )              [data] => array                 (                     [58cf4935572d6e32900057ab] => array                         (                             [age-sex-distribution] => array                                 (                                     [age-range] => array                                         (                                             [options] => below-1                                         )                                      [gender] => array                                         (                                             [male-distribution-count] => 12                                             [female-distribution-count] => 12                                         )                                  )                          )                  )              [date] => 2017-07-08         )      [1] => array         (             [_id] => array                 (                     [purok] => test                     [year] => 2017                     [options] => toddlers (1-2)                 )              [data] => array                 (                     [58cf4935572d6e32900057ab12] => array                         (                             [age-sex-distribution] => array                                 (                                     [age-range] => array                                         (                                             [options] => toddlers (1-2)                                         )                                      [gender] => array                                         (                                             [male-distribution-count] => 12                                             [female-distribution-count] => 12                                         )                                  )                          )                  )              [date] => 2017-07-08         )  ) 

i need check [options] => below-1 if exists. 1 exist, need data in array.

so far, have tried one.

$keysearch = "data.options"; $dataoption = array_search("below-1", array_column($rec, $keysearch)); print_r($dataoption); 

but got no result.

thanks helping me in advance.

$temp = [];  ($data $value){    if($value['_id']['options'] == 'below-1'){        $temp[] = $value;     } }  print_r($temp); 

you can try


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -