note 120411 deleted from function.array-walk-recursive by crell

From: Date: Tue, 12 Apr 2022 01:07:15 +0000
Subject: note 120411 deleted from function.array-walk-recursive by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218200@lists.php.net to get a copy of this message
Note Submitter: webdiecinove at gmail dot com ---- If you want print a multidimensional array, you could try this (the array I use is just an example). Then, I use array_walk_recursive with a function that checks the type of items: $arraytest=array(); $arraytest["firstlev1"] = "First level"; $arraytest["firstlev2"] = array( 0 => array( "secondlev11"=>"Title1", "secondlev12"=>"Subtitle1", "secondlev13" => array( 0 => array("othertitle"=>"other title", "othersubtitle"=>"other sub title"), 1 => array("info"=>"Informations", "otherinfo"=>"Other info") ) ), 1 => array( "secondlev21"=>"Title2", "secondlev22"=>"Subtitle2" ) ); function testitems($theitem,$thekey){ if(is_array($theitem)){ foreach($theitem as $thekey=> $theitem2){ echo "<br>the key: $thekey..........the item: $theitem2"; } } else{ echo "<br>the value: $theitem"; } } array_walk_recursive($arraytest, 'testitems');

« previous php.notes (#218200) next »