|
Posted by lawpoop on 03/26/07 19:48
Hello folks -
I'm working on a function to map a php project that's gotten a little
unwieldly. I'd like to have a reference of all files like the output
of the unix tree command, like this:
..
|-- index.php
| |-- menu.php
| |-- content.php
| |-- admin_page.php
| | |-- admin_function1.php.inc
| | |-- admin_function2.php.inc
| | |-- admin_function3.php.inc
| | `-- admin_subpage.php
| | |-- admin_subfunction1.php.inc
| | |-- admin_subfunction1.php.inc
| | `-- admin_subfunction1.php.inc
| `-- user_page.php
| |-- user_function1.php.inc
| |-- user_function2.php.inc
| |-- user_function3.php.inc
| `-- user_subpage.php
| |-- user_subfunction1.php.inc
| |-- user_subfunction1.php.inc
| `-- user_subfunction1.php.inc
|
|-- orphan_page.php
`-- deprecated_page.php
I have a function that can create such text output ( or close enough )
from an array structure like this:
Array (
[0] => ./index.php
[1] => Array (
[0] => ./clients.php
[1] => Array (
[0] => ./login_function.inc
[1] => ./client.php
[2] => ./client_new.php
[3] => ./client_edit.php
)
[2] => ./inventory.php
[3] => Array (
[0] => ./login_function.inc
[1] => ./inventory_item_add.php
[2] => ./inventory_item_remove.php
)
[4] => ./daily_report.php
[5] => ./weekly_report.php
[6] => ./monthly_report.php
[7] => ./catalog.php
[8] => Array (
[0] => ./login_function.inc
[1] => ./catalog_item_add.php
[2] => ./catalog_item_remove.php
)
[9] => ./orders.php
[10] => Array (
[0] => ./login_function.inc
[1] => ./view_order.php
[2] => ./order_new.php
[3] => ./order_edit.php
)
[11] => ./invoices.php
[12] => Array (
[0] => ./login_function.inc
[1] => ./view_invoice.php
[2] => ./invoice_new.php
[3] => ./invoice_edit.php
[4] => ./invoice_print.php
[5] => ./invoice_email.php
)
)
[2] => ./clients_old.php
[3] => ./old_inventory.php
However, now I'm having a problem building the array of files!
Starting with a default root file, index.php, I can loop through each
file and find each .php or .inc file. Then I can create an array like
Array (
[0] => ./index.php
[1] => Array (
[0] => ./clients.php
[2] => ./inventory.php
[4] => ./daily_report.php
[5] => ./weekly_report.php
[6] => ./monthly_report.php
[7] => ./catalog.php
[9] => ./orders.php
[11] => ./invoices.php
[2] => ./clients_old.php
[3] => ./old_inventory.php
)
Then, I need to go through each element and find out what files are
referenced in that file, and insert that array. So I would get:
Array (
[0] => ./index.php
[1] => Array (
[0] => ./clients.php
[1] => Array (
[0] => ./login_function.inc
[1] => ./client.php
However, I'm having problems getting started. What function can I use
to insert an array at a certain point?
[Back to original message]
|