3v4l.org

run code in 300+ PHP versions simultaneously
<?php mb_internal_encoding('UTF-8'); $text = <<<TEXT Павел Дуров fsdf sdf sdf TEXT; $filter = 'Павел Дуров'; $filter = mb_strtolower($filter); $parts = explode(' ', $filter); $parts = array_map('trim', $parts); $parts = array_map('preg_quote', $parts); $filter = implode('.*', $parts); // echo preg_match("~{$filter}~uis", $text); $a = mb_split('[\x00-\x20]+', $text); $a = array_map('trim', $a); $a = array_filter($a); print_r($a);
Output for 7.1.7, 7.3.24 - 7.3.33, 7.4.12 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Array ( [1] => Павел [2] => Дуров [3] => fsdf [4] => sdf [5] => sdf )

preferences:
107.53 ms | 403 KiB | 115 Q