3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ["foo" => "bar1", "hey" => "now"], ["foo" => "bar2", "hey" => "what"], [0 => "zero", 1 => "one"] ]; var_export(array_column($array, 'foo')); // get the column by name echo "\n---\n"; var_export(array_column($array, 0)); // don't need to be a string echo "\n---\n"; var_export(array_column($array, key(current($array)))); // access the first subarray, access its key echo "\n---\n"; var_export(array_column($array, array_shift(array_keys($array))));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => 'bar1', 1 => 'bar2', ) --- array ( 0 => 'zero', ) --- array ( 0 => 'bar1', 1 => 'bar2', ) --- Notice: Only variables should be passed by reference in /in/hH79U on line 14 array ( 0 => 'zero', )

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:
29.91 ms | 406 KiB | 5 Q