Unix tree convert to recursive php array
        Posted  
        
            by Fordnox
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Fordnox
        
        
        
        Published on 2010-05-14T16:18:25Z
        Indexed on 
            2010/05/14
            20:34 UTC
        
        
        Read the original article
        Hit count: 361
        
I have a response from remote server like this:
/home/computer/Downloads
|-- /home/computer/Downloads/Apple
|   `-- /home/computer/Downloads/Apple/Pad
|-- /home/computer/Downloads/Empty_Folder
`-- /home/computer/Downloads/Subfolder
    |-- /home/computer/Downloads/Subfolder/Empty
    `-- /home/computer/Downloads/Subfolder/SubSubFolder
        `-- /home/computer/Downloads/Subfolder/SubSubFolder/Test
this is the output for command
computer@athome:$ tree -df --noreport -L 5 /home/computer/Downloads/
I would like to parse this string to recursive php array or object, something like this. I would show only part of result to get the idea.
array(
    'title' => '/home/computer/Downloads',
    'children' => array(
        0 => array(
            'title' => '/home/computer/Downloads/Apple',
            'children' => array( ...
        ) 
    )
);
Response from server can change according to scanned directory. Can someone help me write this function.
Please note that this is response from remote server and php functions can not scan any remote dir.
© Stack Overflow or respective owner