note 98335 modified in control-structures.foreach by danbrown

From: Date: Wed, 09 Jun 2010 18:44:33 +0000
Subject: note 98335 modified in control-structures.foreach by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169989@lists.php.net to get a copy of this message
If you're looking for a quick and easy way to recursively pull data from an MD array, here's a little function that should come in handy: <?php /* Grab any values from a multidimensional array using infinite recursion. --Kris */ function RecurseArray( $inarray, $toarray ) { foreach ( $inarray as $inkey => $inval ) { if ( is_array( $inval ) ) { $toarray = $this->RecurseArray( $inval, $toarray ); } else { $toarray[] = $inval; } } return $toarray; } ?> --was-- If you're looking for a quick and easy way to recursively pull data from an MD array, here's a little function that should come in handy: /* Grab any values from a multidimensional array using infinite recursion. --Kris */ function RecurseArray( $inarray, $toarray ) { foreach ( $inarray as $inkey => $inval ) { if ( is_array( $inval ) ) { $toarray = $this->RecurseArray( $inval, $toarray ); } else { $toarray[] = $inval; } } return $toarray; } http://php.net/manual/en/control-structures.foreach.php

« previous php.notes (#169989) next »