note 101950 added to function.array-values

From: Date: Wed, 19 Jan 2011 20:23:28 +0000
Subject: note 101950 added to function.array-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-175909@lists.php.net to get a copy of this message
I needed a function that recursively went into each level of the array to order (only the indexed) arrays... and NOT flatten the whole thing. Solution: <?php function array_values_recursive($arr){ $arr = array_values($arr); foreach($arr as $key => $val) if(array_values($val) === $val) $arr[$key] = array_values_recursive($val); return $arr; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 64.25.226.235 ---- Manual Page -- http://www.php.net/manual/en/function.array-values.php Edit -- https://master.php.net/note/edit/101950 Del: integrated -- https://master.php.net/note/delete/101950/integrated Del: useless -- https://master.php.net/note/delete/101950/useless Del: bad code -- https://master.php.net/note/delete/101950/bad+code Del: spam -- https://master.php.net/note/delete/101950/spam Del: non-english -- https://master.php.net/note/delete/101950/non-english Del: in docs -- https://master.php.net/note/delete/101950/in+docs Del: other reasons-- https://master.php.net/note/delete/101950 Reject -- https://master.php.net/note/reject/101950 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175909) next »