3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ( Array ( 'sexo_edad' => 'type1', 'fans' => 2 ), Array ( 'sexo_edad' => 'type2', 'fans' => 3 ), Array ( 'sexo_edad' => 'type1', 'fans' => 8 ), Array ( 'sexo_edad' => 'type2', 'fans' => 10 ) ); $type_values = array(); foreach ($array as &$arr) { if (isset($type_values[$arr['sexo_edad']])) { $arr['difference'] = $arr['fans'] - $type_values[$arr['sexo_edad']]; } else { $arr['difference'] = 0; } $type_values[$arr['sexo_edad']] = $arr['fans']; } print_r($array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [0] => Array ( [sexo_edad] => type1 [fans] => 2 [difference] => 0 ) [1] => Array ( [sexo_edad] => type2 [fans] => 3 [difference] => 0 ) [2] => Array ( [sexo_edad] => type1 [fans] => 8 [difference] => 6 ) [3] => Array ( [sexo_edad] => type2 [fans] => 10 [difference] => 7 ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.15 ms | 402 KiB | 8 Q