Counting Numbers
Posted: Wed Dec 25, 2002 5:35 pm
Hi. I'm working on a script that takes a number in a line and adds it to the number on the next line... Is there a way i can do this?
Is there a way i can add what it printed? It should get 5700.
Thanks
Code: Select all
<?php
$data1 = XXXXX@XXXXX.COM, 64, 02/11/02, 02:58, 02/11/28, 16:00
XXXXX@XXXXX.COM, 880, 02/11/07, 19:32, 02/12/07, 12:12
XXXXX@XXXXX.COM, 1713, 02/11/07, 20:56, 02/12/07, 23:13
XXXXX@XXXXX.COM, 3043, 02/11/08, 02:16, 02/12/07, 23:49';
$data = preg_split("!\r|\n!", $data1, -1, PREG_SPLIT_NO_EMPTY);
foreach($data as $line)
{
$domain = strstr($line, ',');
$rest = substr("$domain", 1);
$separat = ",";
$string = substr($rest, 0, strlen($rest)-strlen (strstr ($rest,$separat)));
print $string; // Prints 64 880 1713 3043
}
?>Thanks