Jump to content

working out file sizes xml


graham23s

Recommended Posts

Hi Guys,

 

finally got my code done for reading .xml files but when it comes to assigning the results back for the size into mb and gb i don't know what to do

 

this code:

 

     foreach($xml->{"file"} as $nfile) {
     
        $nposter = (string) trim($nfile['poster']);
        $nposter = ($nposter);
                    
        $ndate = 0 + trim($nfile['date']);
                    
        $nsubject = (string) trim($nfile['subject']);
        // To find num of segments in subject:
        $nsubjsegs = 0 + subj_seg($nsubject);
        
        // To find out if Par or not
        $npar = (stristr($nsubject, "par2")?0:1);
        
        $nsubject = ($nsubject);
                    
        $groups = array();
        foreach($nfile->groups->group as $group) {
              $groups[] = (string) trim($group);
        }
        
        $ngroups = (serialize($groups));
        
        $size = 0;
        foreach($nfile->segments->segment as $segment)
        $size += $segment['bytes'];
                          
      }

 

gives back this for the size:

 

52617506

 

can anyone tell me how to go about changing size into 1 more readable like in megabytes and gigabytes.

 

thanks guys

 

Graham

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.