note 41967 added to function.array-values

From: Date: Tue, 27 Apr 2004 22:47:27 +0000
Subject: note 41967 added to function.array-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-68913@lists.php.net to get a copy of this message
<?php /** flatten an arbitrarily deep multidimensional array into a list of its scalar values (may be inefficient for large structures) (will infinite recurse on self-referential structures) (could be extended to handle objects) */ function array_values_recursive($ary) { $lst = array(); foreach( array_keys($ary) as $k ){ $v = $ary[$k]; if (is_scalar($v)) { $lst[] = $v; } elseif (is_array($v)) { $lst = array_merge( $lst, array_values_recursive($v) ); } } return $lst; } ?> code till dawn! -mark meves! ---- Manual Page -- http://www.php.net/manual/en/function.array-values.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41967 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41967&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41967&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68913) next »