3v4l.org

run code in 300+ PHP versions simultaneously
<?php $textos[] = 'yuqkdp69yHryACb778mvZsbFegIBU#'; $textos[] = 'yuqk#p69yHryACb778mvZsbFigIBUh'; $textos[] = 'yuqksp69yHryACb778m#Zs#Fi#IBUh'; $textos[] = 'yuqksp69yHryACb778mvZsbFigIBUh'; $textos[] = 'yuqksp69yHryACb778mvZsb%igIBUh'; $textos[] = 'yuqksp69yHryACb778mvZsbFigIBU&'; $textos[] = 'yuqksp@9yHryACb778mvZsbFigIBUh'; foreach ($textos as $index => $texto) { for ($i = 0; $i < 10000; $i++) { $inicio = microtime(true); tem_simbolo_na_senha($texto); $fim[$index][] = microtime(true) - $inicio; } echo (int)tem_simbolo_na_senha($texto) . ' - '. $texto . ' demorou ' . array_sum($fim[$index]) / count($fim[$index]); echo PHP_EOL; } function tem_simbolo_na_senha($texto) { $return = 0; $tamanho = mb_strlen($texto, '8bit'); for($i = 0; $i < $tamanho; $i++){ $return |= (int)($texto[$i] === "#" xor $texto[$i] === "@" xor $texto[$i] === "%" xor $texto[$i] === "&"); } return $return !== 0; }

preferences:
33.82 ms | 402 KiB | 5 Q