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:
37.23 ms | 402 KiB | 5 Q