Sometimes, we require to generate random string for token or something other login in laravel 5 application. if i remember exactly, 1 year ago i was working on my laravel 5 application at that moment i need to create unique string.
I search on google and laravel docs i found str_random() helper of php laravel framework to generate random string, we need to just give then number as argument and it returns automatic random string. So you can also simply use bellow function, i added syntax and example bellow:
Syntax:
str_random(number);
Example:
$randomString = str_random(25);
dd($randomString);
Output:
8BXYr78JdV1T4DKmTYvc0WLfM
I hope you found your best....
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example