Skip to content

Instantly share code, notes, and snippets.

@pghoratiu
Created April 18, 2011 18:49
Show Gist options
  • Save pghoratiu/925917 to your computer and use it in GitHub Desktop.
Save pghoratiu/925917 to your computer and use it in GitHub Desktop.
tree walk in php
/**
* 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