3v4l.org

run code in 300+ PHP versions simultaneously
<?php function apikey( $length ) { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; $size = strlen( $chars ); $key =""; for( $i = 0; $i < $length; $i++ ) { $str= $chars[ rand( 0, $size - 1 ) ]; echo $str; $key .= $str; } return $key; } $apikey = apikey(32); echo "\noutside function\n"; echo $apikey;

preferences:
22.83 ms | 404 KiB | 5 Q