note 56381 deleted from function.array-values by crell
| From: | crell@php.net | Date: | Tue, 12 Apr 2022 01:06:21 +0000 |
| Subject: | note 56381 deleted from function.array-values by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218196@lists.php.net to get a copy of this message | ||
Note Submitter: Yassin Ezbakhe <yassin88 at gmail dot com>
----
<?php
/**********************************************
*
* PURPOSE: Flatten a deep multidimensional array into a list of its
* scalar values
*
* array array_values_recursive (array array)
*
* WARNING: Array keys will be lost
*
*********************************************/
function array_values_recursive($array)
{
$arrayValues = array();
foreach ($array as $value)
{
if (is_scalar($value) OR is_resource($value))
{
$arrayValues[] = $value;
}
elseif (is_array($value))
{
$arrayValues = array_merge($arrayValues, array_values_recursive($value));
}
}
return $arrayValues;
}
?>
This function is an improved and faster version of the one posted by <27-Apr-2004 09:47>