note 101950 deleted from function.array-values by crell

From: Date: Tue, 12 Apr 2022 01:06:46 +0000
Subject: note 101950 deleted from function.array-values by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218194@lists.php.net to get a copy of this message
Note Submitter: aowie1 at gmail dot com ---- 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; } ?>

« previous php.notes (#218194) next »