3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = ['Jay', 'Jay', 'Jay', 'Spiders', 'Dogs', 'Cats', 'John', 'John', 'John', 'Dogs', 'Cows', 'Snakes']; $new = array( array_shift( $array)); foreach( $array as $el) { if( !($array[count($array) - 1] === $el)) { $new[] = $el; } } print_r( $new);

preferences:
45.86 ms | 402 KiB | 5 Q