note 108779 added to ref.array
| From: | topor-grabowski at viversum dot de | Date: | Thu, 24 May 2012 04:51:37 +0000 |
| Subject: | note 108779 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188186@lists.php.net to get a copy of this message | ||
<?php
//deletes all array entries with $valueToDelete as array entry; does function recursive
//without changing original array
function array_delete_elements($array = null, $valueToDelete = null) {
//no array given
if (!isset($array)) {
return null;
}
//process
$resultList = array();
foreach ($array as $entryKey => $entryValue) {
if (is_array($entryValue)) {
//entry is array and should be handled again recursive
$resultList[$entryKey] = array_delete_elements($entryValue, $valueToDelete);
} else {
if ($entryValue != $valueToDelete) {
$resultList[$entryKey] = $entryValue;
}
}
}
return $resultList;
}
?>
----
Server IP: 212.124.37.9
Probable Submitter: 195.226.123.90
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/108779
Del: integrated -- https://master.php.net/note/delete/108779/integrated
Del: useless -- https://master.php.net/note/delete/108779/useless
Del: bad code -- https://master.php.net/note/delete/108779/bad+code
Del: spam -- https://master.php.net/note/delete/108779/spam
Del: non-english -- https://master.php.net/note/delete/108779/non-english
Del: in docs -- https://master.php.net/note/delete/108779/in+docs
Del: other reasons-- https://master.php.net/note/delete/108779
Reject -- https://master.php.net/note/reject/108779
Search -- https://master.php.net/manage/user-notes.php