herghost Posted January 19, 2012 Share Posted January 19, 2012 Hi all, How do I get the following paths from the array separately in a foreach loop? level.dat level.dat_old session.lock uid.data If I use foreach($outer_dir as $key=>$val) [code] then I get a warning because its returning the folder as 'Array'. The files still upload, as well as a single file called Array. Can i just strip these from the foreach? [code] Array ( [data] => Array ( ) [level.dat] => level.dat [level.dat_old] => level.dat_old [players] => Array ( [herghost.dat] => herghost.dat ) [region] => Array ( [r.-1.0.mcr] => r.-1.0.mcr [r.0.0.mcr] => r.0.0.mcr ) [session.lock] => session.lock [uid.dat] => uid.dat ) herghost.dat Many thanks from a confused user Quote Link to comment Share on other sites More sharing options...
Andy-H Posted January 19, 2012 Share Posted January 19, 2012 foreach( $outer_dir AS $key => $dir ) { if ( is_array($dir) ) continue; // this will skip past players and region ( and anything else that is an array (or multi-dimensional array) // do something } if you want to get the data from players and region, foreach( $outer_dir AS $key => $dir ) { if ( is_array($dir) ) { foreach( $dir AS $k => $inner_dir ) { // do something } } // do something } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.