3v4l.org

run code in 300+ PHP versions simultaneously
<?php $refs = array(); function wrap( $arr){ // Need to clear out the global references array, I chose to do this here global $refs; $refs = array(); test( $arr); } function test( $arr){ global $refs; $refs[] = $arr; foreach( $arr as $v) { if( $v === $arr || in_array( $v, $refs)) { print ' ref '; } else { if( is_array( $v)) { test( $v); } else { print $v . ', '; } } } } echo "Array 1:\n"; $array1 = array(1, 2, 3); $array1[4] = &$array1; wrap( $array1); echo "\nArray 2:\n"; $array2 = array(1, 2, 3, array(1, 2, 3)); $array2[2] = &$array2; wrap( $array2); echo "\nArray 3:\n"; $array3 = array(1, 2, 3, array(1, 2, 3)); $array3[3][1] = &$array3; wrap( $array3);
Output for git.master, git.master_jit, rfc.property-hooks
Array 1: 1, 2, 3, ref Array 2: 1, 2, ref 1, 2, 3, Array 3: 1, 2, 3, 1, ref 3,

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:
38.3 ms | 401 KiB | 8 Q