3v4l.org

run code in 300+ PHP versions simultaneously
<?php function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { $pieces = []; $max = mb_strlen($keyspace, '8bit') - 1; for ($i = 0; $i < $length; ++$i) { $pieces []= $keyspace[random_int(0, $max)]; } return implode('', $pieces); } var_dump(random_str(32)); var_dump(random_str(8, 'abcdefghijklmnopqrstuvwxyz'));
based on b4PST
Output for 7.3.10
string(32) "gehiM4sCXKBcMwD54wLtT2pSx68RdIFa" string(8) "ehtvfrqk"
Output for 7.3.9
string(32) "ycPxhi07k6iDKYI1YfxkPabzRpRSYAVl" string(8) "vewteomd"
Output for 7.3.8
string(32) "49ioYgTB5QWPk5s6Y0UnWpf7NpygRqb6" string(8) "zopridnd"
Output for 7.3.7
string(32) "PPVQ6D59b17lKKwIHcZdHw9u2hNI2m3M" string(8) "vomuycze"
Output for 7.3.6
string(32) "UljuWRX9dznhf66DGoYpzcSnr1DUVqHN" string(8) "mnzzuyds"
Output for 7.3.5
string(32) "7pH8Pgr3SsSwaMtmKUeGqloR6MbjcgVE" string(8) "nshmvcnq"
Output for 7.3.4
string(32) "tVPjo44bPvZxFw4jbn6gGvxDjHxk78KC" string(8) "ygzzxxvr"
Output for 7.3.3
string(32) "pLEENBauUciCSbzjgJApCMQxGMHCDf8d" string(8) "ivmdsyda"
Output for 7.3.2
string(32) "QpfBmTKucTIVAIQfqhA3zfsHqEncEjMv" string(8) "nldkxdtv"
Output for 7.3.1
string(32) "Pi68p9INOCo1qjHEmH0YEiFwcO3Zfu9D" string(8) "aonmecvl"
Output for 7.3.0
string(32) "v2ldRO1AEzLAD6xn2zvcJvLHpELCnRxD" string(8) "wfkhvhat"
Output for 7.2.23
string(32) "bRVKTqD7fnhZYTKPTkTWE7K9X4CVCZkZ" string(8) "oudbwluz"
Output for 7.2.22
string(32) "BpvDpnpsWVtTxryBaHzIXNGOgQeYEflD" string(8) "vqvyjbxk"
Output for 7.2.21
string(32) "DC2xV3Z2IdgBWXAN2JMoFHL4YrOBykUy" string(8) "plydjsxr"
Output for 7.2.20
string(32) "zA6m0Xkr9WXSGnU0EnnHjWhzlKbYupJ0" string(8) "hjvgzrsk"
Output for 7.2.19
string(32) "nkKf4jzj2aYtj6hHwU1oRuckHrwsRvK5" string(8) "tbkovxwh"
Output for 7.2.18
string(32) "Y6BVLervzXOl96vGZWelIaG4bEzhLVVX" string(8) "bavwytig"
Output for 7.2.17
string(32) "LHB43FZTwJGMJkcDIUOrtz2Mzg9MbALz" string(8) "xobtviny"
Output for 7.2.16
string(32) "DSm1AQMUAJwnfsXRTCKIBB0Aps7FihDe" string(8) "gbexotdg"
Output for 7.2.15
string(32) "BwuDxEiQSSdnALNDyyWUmsOGUWt9xg7o" string(8) "zyrwbuys"
Output for 7.2.14
string(32) "ZwVZREIYESgpN3rjcBVUS9MdrOsSRQhm" string(8) "fqlivgcv"
Output for 7.2.13
string(32) "d7ge5fyDUyhQ3YMwZ1R5aK0pp5Qkghq1" string(8) "csvwkiqj"
Output for 7.2.12
string(32) "ElBHds8Kl5Zp1PKIUG3oQE2dG25UBuPj" string(8) "zeijjxqz"
Output for 7.2.11
string(32) "2zq8uFbiJhucLVz1dwWNPYJg651Jg9aD" string(8) "zxcgmlva"
Output for 7.2.10
string(32) "Wd2k7mRaqnNUm8X9qNZGF873q7Xz9k0l" string(8) "itxdljwn"
Output for 7.2.9
string(32) "Oo7PeevK6EWDt5RdSkabEX4HbkqsSqEv" string(8) "yscozahw"
Output for 7.2.8
string(32) "e4E3SQvhliyuJNufQS5xYybk4FNk7ThT" string(8) "mpqmdipu"
Output for 7.2.7
string(32) "3lBpgRh8VJeESAvp1BoehOraZhIOmYmE" string(8) "vvphiwix"
Output for 7.2.6
string(32) "su1u1pjtqpRg1e9EeLdVyJui4zlRS4dD" string(8) "ldrwtyke"
Output for 7.2.5
string(32) "2udrX9bYYl4aVJf7IRXk9r99Vuj1KDGV" string(8) "oljsyawr"
Output for 7.2.4
string(32) "0ZYjnjiyzRoACl4NYMcMMjm0LI2v1biX" string(8) "ryrftixw"
Output for 7.2.3
string(32) "vu39utELnBpEpMkxK7KwZhpCCRlnQSzb" string(8) "avhjczxp"
Output for 7.2.2
string(32) "yq4H6gS2Jurbozsv2dwNhGvZtxRPi0tl" string(8) "adiljoig"
Output for 7.2.1
string(32) "RGsBeGAE2XBatq0mIOzj5IlzVs0aA5Zf" string(8) "vqbmxxcf"
Output for 7.2.0
string(32) "q922WkvnUfPPZCAREUFQhVYDgDI1l8W0" string(8) "yvriywcw"
Output for 7.1.32
string(32) "NUVndw4FKmXMwedcWILn6j3bcSHYhGXM" string(8) "ehdnjukb"
Output for 7.1.31
string(32) "sYeGmvTQ9DEWDYuAiIiHPWgBJbbgf80f" string(8) "likhabsv"
Output for 7.1.30
string(32) "nwwFgplDLlw4vITumcAt6SMXZM4x5C4W" string(8) "apxuegrl"
Output for 7.1.29
string(32) "xa3UeJbColapogVtVs5bB64NsS407xFt" string(8) "mhdvubvn"
Output for 7.1.28
string(32) "i2fwXiESBbpXnuEwvaYZEVYCxQMpKHEK" string(8) "xbnaeivj"
Output for 7.1.27
string(32) "1JhHP3duJ59RuZ5f7AzNhaNJ2omC9xaa" string(8) "ghsblzzu"
Output for 7.1.26
string(32) "mNLZrcmExnYsar9EgzmQZHGoL9kobO5A" string(8) "gpheesrw"
Output for 7.1.25
string(32) "7v7auT97jrQACwLzDxp8IhekcytfbQVJ" string(8) "vzefopwd"
Output for 7.1.24
string(32) "Q7bY3WKbhB6y20cdJcL5IHYlxWyytkUu" string(8) "xaidksno"
Output for 7.1.23
string(32) "Vq5nxtur7hjgKKxk06j7hWEfVNNowmXl" string(8) "jocsonst"
Output for 7.1.22
string(32) "ROZ9GikTEUBNPJz38TIDTUER3te9QLvO" string(8) "zopcpsce"
Output for 7.1.21
string(32) "0EaS2aL26NNmcDdfJCkz5UcTIvdr8YXa" string(8) "rjdpqfqc"
Output for 7.1.20
string(32) "hiaS3BtlZ0wEKRsB3AGr56JmswxYdKF4" string(8) "pelycskt"
Output for 7.1.19
string(32) "hbivzV2hQFl8EdIYtf6CrRtsWuFgIKkR" string(8) "xaaaiith"
Output for 7.1.18
string(32) "2JJCiorjL0vObpCaB8E6m96Qsnpxvp9s" string(8) "dwuqmvve"
Output for 7.1.17
string(32) "qjL4yoD6lEdIoWScXx9Pz5yotUWdvnIv" string(8) "aaubuejw"
Output for 7.1.16
string(32) "KXxyizrdejY2GiPoZjgF2bHx8jyt3dD7" string(8) "cfzcpfjq"
Output for 7.1.15
string(32) "I4rthGqv1Xi0YpKLxma8IJmDBoHT2BSL" string(8) "rcfxexjv"
Output for 7.1.14
string(32) "vtil4rLeaunUWpCwjELGdqYmLoXhmYmv" string(8) "eafspdwt"
Output for 7.1.13
string(32) "J2iun0tUrNf4zo9vAyumOvg2vJc2gLSj" string(8) "wmwvlxgr"
Output for 7.1.12
string(32) "faJnsyYzCi7fchfzDpdbaiEqvB6pcCSo" string(8) "qyueqjqe"
Output for 7.1.11
string(32) "Cft8eV6Erunmk8kHatqBLLOQPNcGaVXD" string(8) "meozizap"
Output for 7.1.10
string(32) "jJUhDB5rRcLwUxCR9IuHLySGRQRYW65Y" string(8) "xyzcubzi"
Output for 7.1.9
string(32) "SkkzytLSvPuyRvJAfn1Rw07KaxcLWbQH" string(8) "qxmylkjv"
Output for 7.1.8
string(32) "JdepttU9uNPJUFUDKSxdUCF0MU7pWrUV" string(8) "yrglayiv"
Output for 7.1.7
string(32) "xmDSa42wjpBr1x6oRURgYc2XCoD6Qyti" string(8) "ailflyod"
Output for 7.1.6
string(32) "QXrq9n7WQppz1nM4WE24eS16QkBFqm1m" string(8) "ojphatwa"
Output for 7.1.5
string(32) "Z1Z1WGp1hx17G8mIT1JBo2zL4EvwRPd7" string(8) "nafkcjjy"
Output for 7.1.4
string(32) "I1OEtCNJL5l1txFokcplMWQhjNQqp1se" string(8) "ibeyqehe"
Output for 7.1.3
string(32) "Q1Bw1xrGEsKuitNcBdPfu8auztvkqNXl" string(8) "iyqnuvqz"
Output for 7.1.2
string(32) "gQIYVW2vYOBx3kZnNR1KHlX1VZaXkrov" string(8) "kzoagqit"
Output for 7.1.1
string(32) "Uy8J3oPXnSKADfFvWjwPwQiTqFmlMWN4" string(8) "duxdcenl"
Output for 7.1.0
string(32) "oOxxCMvyznb3xbplNlPFuasZUjOYKI6I" string(8) "uepeldlk"
Output for 7.0.33
string(32) "GW0NRseOGviuFuBUzfFkJigbl0Pzd6kK" string(8) "wuvmwjry"
Output for 7.0.32
string(32) "02fdtK0zgKO5fo0iXRZbeLBIXe1YHxlY" string(8) "qpymjqmv"
Output for 7.0.31
string(32) "V9xSeBfdeYnRDkYILB8ofye6hwfHBVsa" string(8) "ekxwcmuv"
Output for 7.0.30
string(32) "sTFdqv1CuE8amrEw6PkQIEIWqsHcIqOB" string(8) "znefgjxn"
Output for 7.0.29
string(32) "Is9q6ofAWmjCF3SEzzP7inTIbW8R2Uyo" string(8) "fjtnjmxr"
Output for 7.0.28
string(32) "BE7ePTXmsd9Q4PbYpzP5ozqzcYEhB9eg" string(8) "fgncownj"
Output for 7.0.27
string(32) "a1xclfmoUax6gcVii0Gx2VPOWq5Jg23r" string(8) "slmawpmx"
Output for 7.0.26
string(32) "WL78onlMhXjulVphqE5zbvN4jKq3toTt" string(8) "ogphrqne"
Output for 7.0.25
string(32) "GTbTozK1Ja9XCFP9xmgxtAF9HizTG285" string(8) "gnbprvyg"
Output for 7.0.24
string(32) "YaNxqyNxaHEHl6iXDWDUnlplbkyaNf3S" string(8) "wsfbzqah"
Output for 7.0.23
string(32) "BWN36LvEf0VQYM05kFanlvxfAmo8Q9Ga" string(8) "bjqcjlyw"
Output for 7.0.22
string(32) "GBAfPJ786V7cTTtW5kHvbKmlodC0UBmp" string(8) "hzvfpgup"
Output for 7.0.21
string(32) "eAaNHLQqwhJhnVKxr76cngXz4YUwbEkP" string(8) "hkrzbzuw"
Output for 7.0.20
string(32) "Ms0AZEbjUcI7SYTaw6lelrc3Yv4WzzLh" string(8) "hkvoadkq"
Output for 7.0.19
string(32) "68TX5vJGf0KxZHqv6vrJjUJm4HM9m4Po" string(8) "dlujliio"
Output for 7.0.18
string(32) "sUOOobTE6JGUk3e92xRK3KnIa54xfSfB" string(8) "pjqgmnyl"
Output for 7.0.17
string(32) "Qyd4a1FhINK93FSeTZu1Hj54Fcvw1jO1" string(8) "jzetectu"
Output for 7.0.16
string(32) "HE2xmR5b1raleh97u3oRM0wE2Dxu7X7G" string(8) "bfdgytlk"
Output for 7.0.15
string(32) "F3YO6kF42DCdczvN6eJPA4ubiEooSz3e" string(8) "zdeacouk"
Output for 7.0.14
string(32) "Jaxd2892nE2yS4Xk9oNTKid6lMuHjjlQ" string(8) "wkuirvwd"
Output for 7.0.13
string(32) "JTQN1Otj36kLsG5fifPtqpl8mzN6oJd0" string(8) "sdavrsjj"
Output for 7.0.12
string(32) "7V0O4b523v5yruCbuFK33tN4lBOTHW6R" string(8) "kddzqfrr"
Output for 7.0.11
string(32) "3WAF9HhUnm9l2dRfRzs08KdCAgS44tCM" string(8) "puoneqse"
Output for 7.0.10
string(32) "D2sSRCOqlh7y6AAyGhnoR28C7T1pa7Y5" string(8) "fkvrjgcj"
Output for 7.0.9
string(32) "fAJrExowDTGtYg4Czad0j2KFhy4n2hSC" string(8) "ckvxkfeq"
Output for 7.0.8
string(32) "z90FkNOHXKYKHjmjW0DESl5aXtMg10dq" string(8) "ofyyeqzq"
Output for 7.0.7
string(32) "8JdWgbGFRAyDO4bdY0L9DXnSuHd43z8E" string(8) "xhavssrz"
Output for 7.0.6
string(32) "zmDZk95g7N4mwJNsBYfgOodkm1LuDHGq" string(8) "vkfzwuuw"
Output for 7.0.5
string(32) "cuZU8p5HMU4jCMHBGs1Q2MRqt5xJc6gf" string(8) "adegntux"
Output for 7.0.4
string(32) "rMZP1qrfTgV5j0ZfP20noaoxf8BRNEeo" string(8) "spspbwgd"
Output for 7.0.3
string(32) "gcMZc7lJz6njhll9njYFNu1Y7Xoq5qjq" string(8) "vlmydgoj"
Output for 7.0.2
string(32) "Go93usOXZLpKoaDmcdhdiUh60zyKTMlU" string(8) "ksugkago"
Output for 7.0.1
string(32) "HABlo2CFPbIDP1XVblj2buSjE7FjjSev" string(8) "dozwemlh"
Output for 7.0.0
string(32) "U1YsxMr35hsnOgcAoLlpIVNnraVJOBbl" string(8) "szvqyckt"
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Call to undefined function random_int() in /in/4hMsh on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4hMsh on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/4hMsh on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/4hMsh on line 5
Process exited with code 255.