3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $var = [ 'name' => 'hi', ]; $ref = [ 'name' => 'hi', ]; $context = [ 'var' => $var, 'reference' => &$ref, ]; function func(&$change_me, $context) { $change_me = 2; $context['var']['name'] = 'foo'; $context['reference']['name'] = 'bar'; } $change_me = 1; func($change_me, $context); print_r([$change_me, $context]);
Output for 7.3.0alpha1
Array ( [0] => 2 [1] => Array ( [var] => Array ( [name] => hi ) [reference] => Array ( [name] => bar ) ) )