3v4l.org

run code in 300+ PHP versions simultaneously
<?php function GeneratePassword ($length,$chars) { $res = array(); $char_length = strlen($chars) - 1; for($i = 0; $i < $length; $i++) { $res[] = $chars[rand(0,$char_length)]; } return implode('', $res); } echo GeneratePassword(10, 'asdafdfgsaffhdhsd');

preferences:
34.01 ms | 402 KiB | 5 Q