3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $user = []; $arr = [[ 'chatduration' => 124.502,'username' => 'bhavin'],[ 'chatduration' => 124.502,'username' => 'bhavin']]; foreach($arr as $record){ if (array_key_exists($record['username'],$record)) { $user[$record['username']] = $user[$record['username']] + $record['chatduration']; echo "inside"; } else { $user[$record['username']] = $record['chatduration']; } } print_r($arr);
based on FmSmu
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
Array ( [0] => Array ( [chatduration] => 124.502 [username] => bhavin ) [1] => Array ( [chatduration] => 124.502 [username] => bhavin ) )