Jump to content

Help with counting array output


herghost

Recommended Posts

Hi all

 

What I am trying to achieve is a for each loop for the following output

 

Array ( [result] => success [source] => getDirectory [success] => Array ( [0] => /root/mc/world/data/ [1] => /root/mc/world/level.dat [2] => /root/mc/world/level.dat_old [3] => /root/mc/world/players/ [4] => /root/mc/world/players/herghost.dat [5] => /root/mc/world/region/ [6] => /root/mc/world/region/r.-1.0.mcr [7] => /root/mc/world/region/r.0.0.mcr [8] => /root/mc/world/session.lock [9] => /root/mc/world/uid.dat ) )

 

How would I go about saving each path from the [success] output?

Basically I wish to loop through the array and delete the files.

 

Many Thanks

Link to comment
https://forums.phpfreaks.com/topic/255076-help-with-counting-array-output/
Share on other sites

Thats exactly where I got to before I hit the problem :)

 

Say I am just trying to echo each one with a line break? I cant work out what to call as it is numeric?

 

Cheers

 

Dave

 

If you are trying to output each value on a new line, echo them with a line break.

 

Foreach($arr['success'] as $value){
      echo $value . "<br />";
}

Or you can store the values in an array for later use.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.