Skip to content

Instantly share code, notes, and snippets.

@chrismademe
Created November 22, 2018 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrismademe/2c7e9b5ee410899314857b5f14275537 to your computer and use it in GitHub Desktop.
Save chrismademe/2c7e9b5ee410899314857b5f14275537 to your computer and use it in GitHub Desktop.
Random String in PHP
<?php
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
// Output: 54esmdr0qf
echo substr(str_shuffle($permitted_chars), 0, 10);
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Output: video-g6swmAP8X5VG4jCi.mp4
echo 'video-'.substr(str_shuffle($permitted_chars), 0, 16).'.mp4';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment