3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array('amount'=>100,'date'=>'2014-03-29'), array('amount'=>120,'date'=>'2014-03-30'), array('amount'=>200,'date'=>'2014-03-31'), //array('amount'=>0,'date'=>'2014-04-31') ); function sd($a,$b) {if($a['date'] == $b['date']) return 0; return $a['date'] >$b['date'] ? 1 : -1; usort($arr, 'sd'); $amount = 0; foreach($arr as &$item) { $amount += $item['amount']; $item['amount'] = $amount; } print_r($arr);
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected end of file in /in/mG0Yb on line 18
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected $end in /in/mG0Yb on line 18
Process exited with code 255.

preferences:
193.95 ms | 1398 KiB | 65 Q