I have String array like below format
Array(
"Courses",
"Courses/PHP",
"Courses/PHP/Array",
"Courses/PHP/Functions",
"Courses/JAVA",
"Courses/JAVA/String");
I need result like below
Courses
- PHP
- Array
- Functions
- JAVA
- Strings
I used substr option to get result.
for($i=0;$i<count($outArray);$i++)
{
$strp = strrpos($outArray[$i], '/')+1;
$result[] = substr($outArray[$i], $strp);
}
But I didn't get result like tree structure. How do I get result like tree structure.