3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = 'Date: 2017-07-06 14:37:22 Name: BTC - amount: 0.01106513 - earned: 0.00000001 - rate: 35% Date: 2017-07-06 14:37:21 Name: BTC - amount: 0.08750203 - earned: 0.00000005 - rate: 35% Date: 2017-07-06 14:30:52 Name: BTC - amount: 0.09555558 - earned: 0.00015358 - rate: 34.49%'; $lines = explode(PHP_EOL, $string); $days = []; foreach($lines as $line) { $match = preg_match('/Date\:\s([0-9]+\-[0-9]+\-[0-9]+)\s[^\s]+\sName\:\s([a-zA-Z0-9]+)\s\-\samount\:\s([0-9\.]+)\s\-\searned\:\s([0-9\.]+)\s\-\srate\:\s([0-9\.\%]+)/i', $line, $matches); $date = $matches[1]; $time = $matches[2]; $name = $matches[3]; $amount = $matches[4]; $earned = $matches[5]; $rate = $matches[6]; if(!isset($days[$date])) { $days[$date] = []; } $days[$date][] = [ 'date' => $date, 'name' => $name, 'amount' => $amount, 'earned' => $earned, 'rate' => $rate, 'time' => $time ]; } print_r($days);
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0rc3
Notice: Undefined offset: 6 in /in/mDN7K on line 17 Notice: Undefined offset: 6 in /in/mDN7K on line 17 Notice: Undefined offset: 6 in /in/mDN7K on line 17 Array ( [2017-07-06] => Array ( [0] => Array ( [date] => 2017-07-06 [name] => 0.01106513 [amount] => 0.00000001 [earned] => 35% [rate] => [time] => BTC ) [1] => Array ( [date] => 2017-07-06 [name] => 0.08750203 [amount] => 0.00000005 [earned] => 35% [rate] => [time] => BTC ) [2] => Array ( [date] => 2017-07-06 [name] => 0.09555558 [amount] => 0.00015358 [earned] => 34.49% [rate] => [time] => BTC ) ) )
Output for hhvm-3.15.4
Notice: Undefined index: 6 in /in/mDN7K on line 17 Notice: Undefined index: 6 in /in/mDN7K on line 17 Notice: Undefined index: 6 in /in/mDN7K on line 17 Array ( [2017-07-06] => Array ( [0] => Array ( [date] => 2017-07-06 [name] => 0.01106513 [amount] => 0.00000001 [earned] => 35% [rate] => [time] => BTC ) [1] => Array ( [date] => 2017-07-06 [name] => 0.08750203 [amount] => 0.00000005 [earned] => 35% [rate] => [time] => BTC ) [2] => Array ( [date] => 2017-07-06 [name] => 0.09555558 [amount] => 0.00015358 [earned] => 34.49% [rate] => [time] => BTC ) ) )