Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $id = 2;
- $birth_date = '11-01-2019';
- // We are trying to remove an array that matched the id and birth date above
- $array_values = array (
- array(
- 'id' => 1,
- 'name' => 'Kobe',
- 'email' => 'user_email_1',
- 'birth_date' => '10-22-2019' ),
- array(
- 'id' => 2,
- 'name' => 'Lebron',
- 'email' => 'user_email_2',
- 'birth_date' => '11-01-2019' ),
- array(
- 'id' => 3,
- 'name' => 'Mike',
- 'email' => 'user_email_3',
- 'birth_date' => '10-18-2019' ),
- array(
- 'id' => 4,
- 'name' => 'Magic',
- 'email' => 'user_email_4',
- 'birth_date' => '10-11-2019' )
- );
- foreach($array_values as $key => $value) {
- if ($value['id'] == $id && $value['birth_date'] == $birth_date ) {
- unset($array_values[$key]);
- }
- }
- // We are expecting to remove Lebron. To check:
- echo '<pre>';
- print_r($array_values);
- echo '<pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement