For Programmers: Free Programming Magazines  


Home > Archive > PHP on Windows > April 2006 > Accessing multiple KEY/ITEM pairs using array_walk_recursive









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Accessing multiple KEY/ITEM pairs using array_walk_recursive
Anand

2006-04-06, 6:59 pm

Hello Everyone!!
I have a multidimensional array. I want to get multiple KEY / ITEM pairs
using at array_walk_recursive function.
I want to retrieve all entries where "kind" is "directory"
Example Array:
Array
(
[0] => Array
(
[path] => D:\webs/New Folder
[name] => New Folder
[kind] => directory
[content] => Array
(
[0] => Array
(
[path] => D:\webs/New Folder/index.php
[name] => index.php
[extension] => php
[size] => 138
[kind] => file
)

[1] => Array
(
[path] => D:\webs/New Folder/index___.htm
[name] => index___.htm
[extension] => htm
[size] => 1159
[kind] => file
)

[2] => Array
(
[path] => D:\webs/New Folder/post_test.php
[name] => post_test.php
[extension] => php
[size] => 258
[kind] => file
)

[3] => Array
(
[path] => D:\webs/New Folder/test.htm
[name] => test.htm
[extension] => htm
[size] => 3203
[kind] => file
)

)

)

[1] => Array
(
[path] => D:\webs/SVNAdmin
[name] => SVNAdmin
[kind] => directory
[content] => Array
(
[0] => Array
(
[path] => D:\webs/SVNAdmin/index.htm
[name] => index.htm
[extension] => htm
[size] => 3728
[kind] => file
)

)

)

[2] => Array
(
[path] => D:\webs/test
[name] => test
[kind] => directory
[content] => Array
(
[0] => Array
(
[path] => D:\webs/test/index.htm
[name] => index.htm
[extension] => htm
[size] => 1159
[kind] => file
)

[1] => Array
(
[path] => D:\webs/test/index.php
[name] => index.php
[extension] => php
[size] => 248
[kind] => file
)

[2] => Array
(
[path] => D:\webs/test/myname.php
[name] => myname.php
[extension] => php
[size] => 135
[kind] => file
)

[3] => Array
(
[path] => D:\webs/test/mypagedesign
[name] => mypagedesign
[kind] => directory
[content] => Array
(
[0] => Array
(
[path] =>
D:\webs/test/mypagedesign/admin.txt
[name] => admin.txt
[extension] => txt
[size] => 6
[kind] => file
)

[1] => Array
(
[path] =>
D:\webs/test/mypagedesign/index.htm
[name] => index.htm
[extension] => htm
[size] => 4111
[kind] => file
)

[2] => Array
(
[path] =>
D:\webs/test/mypagedesign/login.gif
[name] => login.gif
[extension] => gif
[size] => 5029
[kind] => file
)

[3] => Array
(
[path] =>
D:\webs/test/mypagedesign/logtest.php
[name] => logtest.php
[extension] => php
[size] => 1380
[kind] => file
)

[4] => Array
(
[path] =>
D:\webs/test/mypagedesign/newaccount.htm
[name] => newaccount.htm
[extension] => htm
[size] => 1005
[kind] => file
)

[5] => Array
(
[path] =>
D:\webs/test/mypagedesign/newaccount.php
[name] => newaccount.php
[extension] => php
[size] => 1009
[kind] => file
)

[6] => Array
(
[path] =>
D:\webs/test/mypagedesign/passwd.txt
[name] => passwd.txt
[extension] => txt
[size] => 80
[kind] => file
)

[7] => Array
(
[path] =>
D:\webs/test/mypagedesign/Trash Dump
[name] => Trash Dump
[kind] => directory
[content] => Array
(
[0] => Array
(
[path] =>
D:\webs/test/mypagedesign/Trash Dump/createFile.php
[name] =>
createFile.php
[extension] =>
php
[size] => 277
[kind] => file
)

[1] => Array
(
[path] =>
D:\webs/test/mypagedesign/Trash Dump/log_me_in.php
[name] =>
log_me_in.php
[extension] =>
php
[size] => 810
[kind] => file
)

[2] => Array
(
[path] =>
D:\webs/test/mypagedesign/Trash Dump/passwd.txt
[name] =>
passwd.txt
[extension] =>
txt
[size] => 96
[kind] => file
)

)

)

)

)

[4] => Array
(
[path] => D:\webs/test/page1.php
[name] => page1.php
[extension] => php
[size] => 295
[kind] => file
)

[5] => Array
(
[path] => D:\webs/test/passwd.txt
[name] => passwd.txt
[extension] => txt
[size] => 96
[kind] => file
)

[6] => Array
(
[path] => D:\webs/test/post_test.php
[name] => post_test.php
[extension] => php
[size] => 258
[kind] => file
)

[7] => Array
(
[path] => D:\webs/test/recursive.php
[name] => recursive.php
[extension] => php
[size] => 3980
[kind] => file
)

[8] => Array
(
[path] => D:\webs/test/testpage.perl
[name] => testpage.perl
[extension] => perl
[size] => 0
[kind] => file
)

)

)

[3] => Array
(
[path] => D:\webs/index.php
[name] => index.php
[extension] => php
[size] => 248
[kind] => file
)

[4] => Array
(
[path] => D:\webs/myfile.php
[name] => myfile.php
[extension] => php
[size] => 250
[kind] => file
)

[5] => Array
(
[path] => D:\webs/recursive.php
[name] => recursive.php
[extension] => php
[size] => 4153
[kind] => file
)

)


Thanks
ANAND
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com