3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = 'test'; $arr = ['test','test2', 'test3', 'test4']; $found = []; if(false !== $key = !array_search($test, $arr)){ $found[] = $key; } print_r($found);

preferences:
44.04 ms | 402 KiB | 5 Q