The file receives the values "1 0 1 -1 -3 1 1 1 1" and the value "154". The php code counts all the digits:
$file = file_get_contents('test.txt'); preg_match_all("/[^\b\d{4}\/\d{2}\/\d{2}\b][0-9\.-]+/", $file, $numbers); foreach($numbers[0] as $num) { $sum = $sum + $num; //складываем } $data = $sum Is it possible to make so that "154" was not considered together with other figures, but was a separate variable? You can enclose a number in any specials. characters and brackets if that helps.