Get paths for all leaf nodes within an
Below is a multimensional arra that I made for testing and I wish to make
a function called getPaths which returns something like the following:
(The function would be called like $path = getPaths($multi_array); )
<?php
$tree = array (
0 => array(
"text" => "Knock-knock.",
"replies" => array(
0 => array(
"text" => "Who is there?",
"replies" => array(
0 => array(
"text" => "Orange.",
"replies" => array()
)
)
),
1 => array(
"text" => "Please, stop knocking.,",
"replies" => array()
)
2 => array(
"text" => "Ring the doorbell.",
"replies" => array(
0 => array(
"text" => "OK, I will ring the
doorbell.",
"replies" => array()
)
1 => array(
"text" => "Where is the doorbell?"
)
)
)
)
)
);
?>
No comments:
Post a Comment