Here is my script:
<?php
$failas = fopen("info.txt", "r");
while (!feof($failas)){
$d = fgets($failas);
$dExploded = explode ( "|", $d );
list($dDate, $dTime) = explode(" ", $dExploded[substr_count($d, "|")]);
$metmen[] = implode('-', explode('-', $dDate, -1));
if(preg_match_all('/[|]\d+[|]/', $d, $match)){
$numbers[] = implode('', $match[0]);
}
}
fclose($failas);
foreach ($numbers as $key=>$value)
{
$naujas[$key] = $metmen[$key] . $numbers[$key];
print $naujas[$key] . "<br>";
}
?>
The output of this script is:
2015-04|500|
2015-04|1200|
2015-04|1000|
2015-04|1500|
2015-04|3400|
2015-03|1500|
2015-02|1500|
2015-03|3000|
I don't have idea how to sum same month |number| numbers. Maby you can help me?