3v4l.org

run code in 300+ PHP versions simultaneously
<?php function alter_macros($content) { preg_match_all('#{(.*)}#Ui', $content, $matches); for($i = 0; $i < count($matches[1]); $i++) { $ns = explode("|", $matches[1][$i]); $c2 = count($ns); $rand = rand(0, ($c2 - 1)); $content = str_replace("{".$matches[1][$i]."}", $ns[$rand], $content); } return $content; } function xnum_macros($content) { preg_match_all('#\[NUM\-([[:digit:]]+)\]#', $content, $matches); for($i = 0; $i < count($matches[0]); $i++) { $num = $matches[1][$i]; $min = pow(10, $num - 1); $max = pow(10, $num) - 1; $rand = rand($min, $max); $content = str_replace($matches[0][$i], $rand, $content); } return $content; } function num_macros($content) { preg_match_all('#\[RAND\-([[:digit:]]+)\-([[:digit:]]+)\]#', $content, $matches); for($i = 0; $i < count($matches[0]); $i++) { $min = $matches[1][$i]; $max = $matches[2][$i]; $rand = rand($min, $max); $content = str_replace($matches[0][$i], $rand, $content); } return $content; } function fteil_macros($content, $fteil) { return str_replace("[FTEIL]", $fteil, $content); } if(!strpos("abc.doc", ".jpg")) { $filename = alter_macros("abc.doc"); $filename = num_macros($filename); $filename = xnum_macros($filename); echo $filename; }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
abc.doc

preferences:
183.95 ms | 404 KiB | 190 Q