I am stuck on something I can't get my head around. Basically I have XML files that need to be read when they are submmitted. I am looking specifically for lines that include:
bytes="345354" I want to extract the int from the bytes tag and add them all up.
The current piece of code I am using does the trick but there is a problem. The code I am using at the moment is:
preg_match_all('|bytes="(.+?)"|', $filecontent, $array);
function arraySumRecursive($array)
{
$total = 0;
foreach(new recursiveIteratorIterator( new recursiveArrayIterator($array)) as $num)
{
$total += $num;
}
return $total;
}
$size = arraySumRecursive($array);
Now this code works all good but it has a problem once it reads an XML file with bytes that add up over 2537792398, it wont't display the correct sum of bytes but always stops at 2537792398 bytes. Granted the XML files are larger but I tested with an XML file with 2 lines and each line has a byte value of greater than 2537792398 and it still only shows 2537792398 bytes as the total sum.
Can anyone tell me what I am doing wrong? I personally have a feeling it has something to with the multi dimensional array but this code is the only one that worked and managed to grab the data for bytes="" . I haven't been able to use any other method of extracting the values and adding them all up to come up with one long byte number.
Any help or pointers in the right direction is appreciated!
Regards,
Tom