3v4l.org

run code in 300+ PHP versions simultaneously
<?php $notifications = []; function add($type){ $notify = array( 'text' => $text , 'link' => $link , 'img' => $img , 'context' => $context ); if ( $notifications && count($notifications[$type]) <= 4 && count($notifications[$type]) ) { 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< 10; $i++){ add($i); }

preferences:
44.68 ms | 402 KiB | 5 Q