Laravel generate random unique string example


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....


July 25, 2017 | 269 Viewer | Category : PHP Laravel
Related Posts:



Blog Search