Last active
December 18, 2015 01:58
-
-
Save annalinneajohansson/5707105 to your computer and use it in GitHub Desktop.
Populera $child_array rekursivt så att sidornas hierarkier bibehålls
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
<?php | |
function populate_children_hierarchically( $child ) { | |
$child_array = array( 'title' => $child->title, 'url' => $child->url ); | |
if( !empty( $child->children ) ) { | |
foreach( $child->children as $granchild ) { | |
$child_array[] = populate_children_hierarchically( $granchild ); | |
} | |
} | |
return $child_array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment