php

Random Code Generator

swindon

Scott Windon

Posted on February 20, 2022

Random Code Generator

Wanted a nice and simple PHP class which could generate random codes. After looking at multiple libraries I found that sometimes it's best done yourself.

The final class can either generate a single code or an array of codes based on the parameters you set.

https://github.com/swindon/code-generator

Example
Generates 8 character long string

(new CodeGenerator)->generate(8);
// output: 4CF9O7XP
Enter fullscreen mode Exit fullscreen mode

Show some support!

Buy me a coffee

💖 💪 🙅 🚩
swindon
Scott Windon

Posted on February 20, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related