3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ "this is a sample test" => "asample test", "sample test1 \n new line content" => "test1 new" ]; $whitechars=[' ',"\t","\r","\n"]; foreach ($tests as $input => $check) { $pattern='~'.preg_replace('~\S(?!$)\K\s*~','\s*',$check).'~'; if(preg_match($pattern,$input)){ echo "Using Pattern: ($pattern) Found: "; }else{ echo "Did Not Find: "; } /* if (strpos(preg_replace('~\s+~', '', $input), preg_replace('~\s+~', '', $check))!==false){ echo "Found: "; }else{ echo "Did Not Find: "; } */ /* if (strpos(str_replace($whitechars, '', $input), str_replace($whitechars, '', $check))!==false){ echo "Found: "; }else{ echo "Did Not Find: "; } */ echo "$check IN $input"; echo "\n---\n"; }

preferences:
33.26 ms | 405 KiB | 5 Q