php - How to get value of array by checking its value -


how can object has value of [existence] == 1

if [existence] == 1 want object has [existence] == 1

and remove [existence] == 0

this array .

array (      [0] => array         (             [id] => 3             [accountcode_naisen] =>              [extentype] => 0             [extenrealname] =>              [name] => 0090000270             [extenktaiemail] =>              [secret] => myojyo42_f             [username] => 0090000270             [guestipaddr] => 192.168.236.15             [participantsetting] => array                 (                     [id] => 13                     [existence] => 1                     [leader] => 1                     [simultaneous] =>                  )          )  ) 

this code far

 foreach ($participants $participant=>$c) {              if ($c['existence'] != 1) {               unset($participants[$participant]);             }            } 

and getting error message **********

[30-sep-2015 15:42:38] php notice: use of undefined constant participantsetting - assumed 'participantsetting' in index.php on line 253

you use more efficient loop. use array_filter() anonymous function callback. this

$participants = array_filter(     $participants,     function($element) { return $element['participantsetting']['existence'] == 1; } ); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -