Created
April 18, 2011 18:49
-
-
Save pghoratiu/925917 to your computer and use it in GitHub Desktop.
tree walk in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returneaza rezultatul sub forma unui array flat pe care poti | |
* sa-l transformi usor intr-un string | |
*/ | |
tree_walk_recursive($src) | |
{ | |
$result = array(); | |
foreach($src as $key => $value) | |
{ | |
if (is_array($value)) | |
{ | |
$result[] = $key; | |
$result += process_array($value); | |
} | |
else | |
{ | |
$result[] = $value; | |
} | |
} | |
return $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment