note 82950 added to function.array-slice

From: Date: Sat, 03 May 2008 04:21:06 +0000
Subject: note 82950 added to function.array-slice
Groups: php.notes 
Request: Send a blank email to php-notes+get-139017@lists.php.net to get a copy of this message
based on worldclimb's arem(), here is a recursive array value removal tool that can work with multidimensional arrays. function remove_from_array($array,$value){ $clear = true; $holding=array(); foreach($array as $k => $v){ if (is_array($v)) { $holding [$k] = remove_from_array ($v, $value); } elseif ($value == $v) { $clear = false; } elseif($value != $v){ $holding[$k]=$v; // removes an item by combing through the array in order and saving the good stuff } } if ($clear) return $holding; // only pass back the holding array if we didn't find the value } ---- Server IP: 208.69.120.35 Probable Submitter: 71.80.132.215 ---- Manual Page -- http://www.php.net/manual/en/function.array-slice.php Edit -- https://master.php.net/note/edit/82950 Del: integrated -- https://master.php.net/note/delete/82950/integrated Del: useless -- https://master.php.net/note/delete/82950/useless Del: bad code -- https://master.php.net/note/delete/82950/bad+code Del: spam -- https://master.php.net/note/delete/82950/spam Del: non-english -- https://master.php.net/note/delete/82950/non-english Del: in docs -- https://master.php.net/note/delete/82950/in+docs Del: other reasons-- https://master.php.net/note/delete/82950 Reject -- https://master.php.net/note/reject/82950 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139017) next »