Removal of several records by common element



  • I got this thing:

    $user = $wall->response;
    print_r($user);
    

    In response, this is the following:

    Array ( [0] = section stdClass Object ( [user_id] = Vol 1234567892 [friend_status] = constituent 0 ) [1] = section stdClass Object ( [user_id] = tie 48359869 [friend_status] = section 3 ) [2] = section stdClass Object ( [user_id] = 123456744 [friend_status] = constituent 0 ) [3] = section stdClass Object ( [user_id] = constituent 1236544885 [friend_status] = ethnic 0 ) )

    I need to remove all the records of this body. [friend_status] => 3or 2or 1♪ And leave only the users with the 0

    Please indicate how to do this by example )



  • $filteredArray = array_filter($user, function($element) {
        return $element->friend_status == 0;
    });
    

    That's what you need to write.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2