3v4l.org

run code in 300+ PHP versions simultaneously
<?php $notifications = array(); function add($type){ global $notifications; $notify = array( 'text' => '11' , 'link' => '22' ); if ( $notifications && count($notifications[$type]) && count($notifications[$type]) <= 4 ) { array_unshift($notifications[$type], $notify); } elseif ( $notifications && count($notifications[$type]) > 4 ) { array_pop($notifications[$type]); array_unshift($notifications[$type], $notify); } else { $notifications[$type] = []; array_unshift($notifications[$type], $notify); } } for($i = 0; $i< 5; $i++){ add($i); var_dump($notifications); }
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { [0]=> array(1) { [0]=> array(2) { ["text"]=> string(2) "11" ["link"]=> string(2) "22" } } } Warning: Undefined array key 1 in /in/631n7 on line 11 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/631n7:11 Stack trace: #0 /in/631n7(34): add(1) #1 {main} thrown in /in/631n7 on line 11
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:
47.06 ms | 402 KiB | 8 Q