3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'Bob' => 2, 'Theresa' => 3, 'The farm house' => 2, 'Bob at the farm house' => 1, ); $result = $array; $removed = &$result; foreach($removed as $key => $value) { foreach($removed as $test => $value) { if (false !== stripos($test, $key)) { unset($removed[$test]); } } } print_r($result);

preferences:
36.95 ms | 402 KiB | 5 Q