3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function ppr($array){ echo '<pre>'; print_r($array); echo '</pre>'; } $brand = 'Fox'; $list = array('Ape','Bat','Cat','Dog','Elk','Fox','Gnu','Hen'); $list = array_diff($list,array($brand)); ppr($list); $list = array_diff($list,array($brand)); ppr($list); array_unshift($list,$brand); ppr($list);
Output for 4.3.0 - 7.1.0
<pre>Array ( [0] => Ape [1] => Bat [2] => Cat [3] => Dog [4] => Elk [6] => Gnu [7] => Hen ) </pre><pre>Array ( [0] => Ape [1] => Bat [2] => Cat [3] => Dog [4] => Elk [6] => Gnu [7] => Hen ) </pre><pre>Array ( [0] => Fox [1] => Ape [2] => Bat [3] => Cat [4] => Dog [5] => Elk [6] => Gnu [7] => Hen ) </pre>