3v4l.org

run code in 300+ PHP versions simultaneously
<?php function makeRandomPath($dir, $ext) { do { $path = $dir."/".genRandomString().".".$ext; } while(file_exists($path)); return $path; } echo makeRandomPath(); function makeRandomPathFromFilename($dir, $fn) { $ext = pathinfo($fn, PATHINFO_EXTENSION); return makeRandomPath($dir, $ext); } echo makeRandomPathFromFilename();

preferences:
44.28 ms | 402 KiB | 5 Q