note 100355 deleted from book.array by danbrown

From: Date: Sun, 10 Oct 2010 23:28:52 +0000
Subject: note 100355 deleted from book.array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173123@lists.php.net to get a copy of this message
Note Submitter: joseph dot davidson dot 707 at gmail dot com ---- perform a set of operations on each set element of a multi-dimensional array no matter the size. (I posted before but grabbed the wrong snippit. Please use this and delete the commentary here.) function dCount($mdArray) { //* $baseType = gettype($mdArray); //* if($baseType == 'array') { //* $count = 0; //* $type = $baseType; //* while($type == 'array') { //* $mdArray = current($mdArray); $type = gettype($mdArray); $count++; //* } //* } else return false; //*/// return $count; //*/// } function mdArray($array) { $baseType = gettype($array); $baseCount = count($array); //print 'BaseCount: ' . $baseCount . '<br>'; for($x = 0; $x < $baseCount; $x++) { //* if(gettype(current($array)) == 'array') { //* $drop = current($array); //* $dCount = $this->dCount($drop); //* $count = count($drop); //print '<br>' . $dCount . ' * ' . $count . '<br>'; //* for($z = 0; $z < $dCount; $z++) { //* $count = count($drop); //* for($y = 0; $y < $count; $y++) { //*CODE HERE -------------------------*** print current($drop) . '/'; //* next($drop); //* } //* print '<br>'; //* $drop = reset($drop); //* } //* } else print 'duplicate code here'; //* next($array); //* } //* }

« previous php.notes (#173123) next »