3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "23456789ABCDEGHJKMNPQRSTUVXYZabcdeghjkmnpqrstuvxyz"; $excludes = ['cp','cb','ck','c6','c9','rn','rm','mm','co','do','cl','db','qp','qb','dp','ww']; $length = 5; $indexedExcludes = array_combine($excludes, $excludes); $dictionaryArray = str_split($str); function fastCaptcha(array $dictionary, array $excludedSyllables, int $length): string { $captcha = ''; $previousCharacter = ''; $generatedLength = 0; while ($generatedLength < $length) { $randomCharacter = $dictionary[array_rand($dictionary)]; if(array_key_exists($previousCharacter . $randomCharacter, $excludedSyllables)) { continue; } $captcha .= $randomCharacter; $previousCharacter = $randomCharacter; $generatedLength++; } return $captcha; } $excludesRegex = '/' . implode('|', $excludes) . '/'; function fuckedCaptcha(string $dictionary, string $excludedSyllables, int $length): string { do { $code = substr(str_shuffle(str_repeat($dictionary, 3)), 0, $length); } while (preg_match($excludedSyllables, $code)); return $code; } $t0 = microtime(true); for ($i = 0; $i < 100000; $i++) fuckedCaptcha($str, $excludesRegex, $length); $t1 = microtime(true); for ($i = 0; $i < 100000; $i++) fastCaptcha($dictionaryArray, $indexedExcludes, $length); $t2 = microtime(true); echo "regexp : " . ($t1 - $t0) . "\n"; echo "array index: " . ($t2 - $t1) . "\n";
Output for git.master_jit
regexp : 0.2460629940033 array index: 0.064589977264404
Output for git.master
regexp : 0.24365997314453 array index: 0.06610107421875
Output for rfc.property-hooks
regexp : 0.23608493804932 array index: 0.06958794593811

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
59.39 ms | 407 KiB | 5 Q