note 69269 deleted from function.array-values by crell

From: Date: Tue, 12 Apr 2022 01:05:03 +0000
Subject: note 69269 deleted from function.array-values by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218183@lists.php.net to get a copy of this message
Note Submitter: wellandpower at hotmail.com ---- The function here flatterns an entire array and was not the behaviour I expected from a function of this name. I expected the function to flattern every sub array so that all the values were aligned and it would return an array with the same dimensions as the imput array, but as per array_values() adjusting the keys rater than removing them. In order to do this, you will want this function: function array_values_recursive($array) { $temp = array(); foreach ($array as $value) { if(is_array($value)) { $temp[] = array_values_recursive($value); } else { $temp[] = $value; } } return $temp; } Hopefully this will assist.

« previous php.notes (#218183) next »