note 68623 added to function.array-diff
| From: | php-general at lists dot php dot net | Date: | Thu, 03 Aug 2006 19:30:30 +0000 |
| Subject: | note 68623 added to function.array-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115525@lists.php.net to get a copy of this message | ||
array_diff provides a handy way of deleting array elements by their value, without having to unset
it by key, through a lengthy foreach loop and then having to rekey the array.
<?php
//pass value you wish to delete and the array to delete from
function array_delete( $value, $array)
{
$array = array_diff( $array, array($value) );
return $array;
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 209.152.81.83
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-diff.php
Edit -- https://master.php.net/note/edit/68623
Del: integrated -- https://master.php.net/note/delete/68623/integrated
Del: useless -- https://master.php.net/note/delete/68623/useless
Del: bad code -- https://master.php.net/note/delete/68623/bad+code
Del: spam -- https://master.php.net/note/delete/68623/spam
Del: non-english -- https://master.php.net/note/delete/68623/non-english
Del: in docs -- https://master.php.net/note/delete/68623/in+docs
Del: other reasons-- https://master.php.net/note/delete/68623
Reject -- https://master.php.net/note/reject/68623
Search -- https://master.php.net/manage/user-notes.php