Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $id = 2;
  3. $birth_date = '11-01-2019';
  4. // We are trying to remove an array that matched the id and birth date above
  5. $array_values = array (
  6. array(
  7. 'id' => 1,
  8. 'name' => 'Kobe',
  9. 'email' => 'user_email_1',
  10. 'birth_date' => '10-22-2019' ),
  11. array(
  12. 'id' => 2,
  13. 'name' => 'Lebron',
  14. 'email' => 'user_email_2',
  15. 'birth_date' => '11-01-2019' ),
  16. array(
  17. 'id' => 3,
  18. 'name' => 'Mike',
  19. 'email' => 'user_email_3',
  20. 'birth_date' => '10-18-2019' ),
  21. array(
  22. 'id' => 4,
  23. 'name' => 'Magic',
  24. 'email' => 'user_email_4',
  25. 'birth_date' => '10-11-2019' )
  26. );
  27. foreach($array_values as $key => $value) {
  28. if ($value['id'] == $id && $value['birth_date'] == $birth_date ) {
  29. unset($array_values[$key]);
  30. }
  31. }
  32. // We are expecting to remove Lebron. To check:
  33. echo '<pre>';
  34. print_r($array_values);
  35. echo '<pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement