3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array( 'id' => 1, 'user_name'=>'test1' ), array( 'id' => 2, 'user_name'=>'test2' ), array( 'id' => 3, 'user_name'=>'test3' ) ); $arr2 = array( array( 'id' => 1, 'shop_name'=>'shop1' ), array( 'id' => 5, 'shop_name'=>'shop2' ), array( 'id' => 3, 'shop_name'=>'shop3' ) ); $tmp = ''; foreach ($arr2 as $k) { $tmp[$k['id']] = $k; } foreach ($arr as &$v) { $sn = $tmp[$v['id']]['shop_name']; $sn = $sn ? $sn :''; $v['shop_name'] = $sn; } var_dump($arr);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Array to string conversion in /in/880dk on line 32 Warning: Only the first byte will be assigned to the string offset in /in/880dk on line 32 Warning: Array to string conversion in /in/880dk on line 32 Warning: Only the first byte will be assigned to the string offset in /in/880dk on line 32 Warning: Array to string conversion in /in/880dk on line 32 Warning: Only the first byte will be assigned to the string offset in /in/880dk on line 32 Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/880dk:34 Stack trace: #0 {main} thrown in /in/880dk on line 34
Process exited with code 255.

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