M.O.S. Studios Posted April 30, 2009 Share Posted April 30, 2009 hey guys, I want to make the key of a array the path of a file, and the value the name of the file. how ever i cant seem to figure this out, any one have any ideas? here is my code: $menus=scandir("common/menu"); for($m=0; $m<=count($menus); $m++) { if($menus[$m]!="." && $menus[$m]!=".." && $menus[$m]) { $key="common/menu/".$menus[$m]; $menu_include[$key]=$menus[$m]; } } thanks in advance Link to comment https://forums.phpfreaks.com/topic/156292-solved-making-a-key-in-an-array/ Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 foreach ($menus as $path => $filename) Does the trigger any thoughts? Link to comment https://forums.phpfreaks.com/topic/156292-solved-making-a-key-in-an-array/#findComment-822826 Share on other sites More sharing options...
M.O.S. Studios Posted April 30, 2009 Author Share Posted April 30, 2009 figured it out, the code above was correct, My problem was that i had used the sort() function lower down on the page. so when i looked at my array it had deleted the keys, i fixed it by useing the asort function instead Link to comment https://forums.phpfreaks.com/topic/156292-solved-making-a-key-in-an-array/#findComment-822843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.