Created
April 19, 2016 14:09
-
-
Save igoralves1/b2d9c7e3ed335309afbffcadbcfe68cb to your computer and use it in GitHub Desktop.
PHP - Remove an array element in a loop? Remover um elemento da array a cada ciclo do loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$arr1v=Array | |
( | |
"2016-04-11 17:16:59"=> "2016-04-11 17:16:59", | |
"2016-04-14 16:47:18"=> "2016-04-14 16:47:18", | |
"2016-04-14 15:39:30" => "2016-04-14 15:39:30", | |
"2016-04-12 15:35:46" => "2016-04-12 15:35:46", | |
'2016-04-14 15:31:43'=> "2016-04-14 15:31:43", | |
'2016-04-14 15:27:10'=> "2016-04-14 15:27:10", | |
'2016-04-14 14:59:45' => '2016-04-14 14:59:45', | |
'2016-04-15 13:41:22'=> '2016-04-15 13:41:22', | |
'2016-04-14 13:18:07'=> '2016-04-14 13:18:07', | |
'2016-04-14 13:15:06'=> '2016-04-14 13:15:06', | |
'2016-04-18 12:42:59' => '2016-04-18 12:42:59', | |
'2016-04-14 12:06:04' => '2016-04-14 12:06:04', | |
'2016-04-14 12:02:57' => '2016-04-14 12:02:57', | |
'2016-04-16 11:13:07'=> '2016-04-16 11:13:07', | |
'2016-04-17 09:49:27' => '2016-04-17 09:49:27' | |
); | |
foreach ($arr1v as $key => $value) { | |
//1-Do some stuff with $arr1v[$key]; Fazer alguma coisa desejada com $arr1v[$key] | |
//2-Delete from array using unset($arr1v[$key]); Deletar o elemento $arr1v[$key] usando unset($arr1v[$key]) | |
//3-Test the result with echo e print_r. Fazer o teste com echo e print_r | |
echo "<pre>"; | |
print_r( $arr1v); | |
echo "</pre>"; | |
unset($arr1v[$key]); | |
} | |
//Array should be empty. Array devera estar vazia | |
echo "<pre>"; | |
print_r( $arr1v); | |
echo "</pre>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment