note 56381 added to function.array-values
| From: | YassinEzbakhe | Date: | Wed, 31 Aug 2005 23:28:07 +0000 |
| Subject: | note 56381 added to function.array-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-94559@lists.php.net to get a copy of this message | ||
<?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>
----
Manual Page -- http://www.php.net/manual/en/function.array-values.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56381
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56381&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56381&report=yes
Search -- http://master.php.net/manage/user-notes.php