note 104088 added to function.unset
| From: | Metasansana at osu1 dot php dot net | Date: | Sun, 22 May 2011 04:19:02 +0000 |
| Subject: | note 104088 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179934@lists.php.net to get a copy of this message | ||
A simple function to unset unwanted keys in an array:
<?php
$a = array("A"=>1, "B"=>2, "C"=>"a");
foreach($a as $key=>&$value){
if(is_string($value){
unset($a[$key]);
}
}
print_r($a);
?>
This should print: A=1 B=2.
----
Server IP: 69.147.83.197
Probable Submitter: 190.213.25.166
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- https://master.php.net/note/edit/104088
Del: integrated -- https://master.php.net/note/delete/104088/integrated
Del: useless -- https://master.php.net/note/delete/104088/useless
Del: bad code -- https://master.php.net/note/delete/104088/bad+code
Del: spam -- https://master.php.net/note/delete/104088/spam
Del: non-english -- https://master.php.net/note/delete/104088/non-english
Del: in docs -- https://master.php.net/note/delete/104088/in+docs
Del: other reasons-- https://master.php.net/note/delete/104088
Reject -- https://master.php.net/note/reject/104088
Search -- https://master.php.net/manage/user-notes.php