3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $format = 'AAA-###000'; $voucherCode = ''; $charSet = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; //removed O and I, they can easily be mistaken for numbers $numberSet = '0123456789'; $length = strlen($format); $charCount = strlen($charSet); $numberCount = strlen($numberSet); for ($i=0; $i < $length; $i++) { if ($format[$i] == '#') //alpha $voucherCode .= substr($charSet, mt_rand(0, $charCount-1), 1); elseif($format[$i] == '0') //numerical $voucherCode .= substr($numberSet, mt_rand(0, $numberCount-1), 1); else //specific alpha character $voucherCode .= $format[$i]; } echo $voucherCode;
Output for 7.1.0
AAA-QRA728
Output for 7.0.14
AAA-WJJ909
Output for 7.0.10
AAA-DUY560
Output for 7.0.9
AAA-XUM643
Output for 7.0.8
AAA-VST497
Output for 7.0.7
AAA-YCY141
Output for 7.0.6
AAA-ALK474
Output for 7.0.5
AAA-DZB456
Output for 7.0.4
AAA-QKX006
Output for 7.0.3
AAA-HXU928
Output for 7.0.2
AAA-SDP936
Output for 7.0.1
AAA-ZQX600
Output for 7.0.0
AAA-YEY970
Output for hhvm-3.12.0
AAA-XBP786
Output for hhvm-3.10.0
AAA-DAT924
Output for 5.6.28
AAA-QVH007
Output for 5.6.25
AAA-RME780
Output for 5.6.24
AAA-XHS899
Output for 5.6.23
AAA-NQE784
Output for 5.6.22
AAA-CUB618
Output for 5.6.21
AAA-GVB655
Output for 5.6.20
AAA-AKX530
Output for 5.6.19
AAA-KFH258
Output for 5.6.18
AAA-JBC197
Output for 5.6.17
AAA-ZDS362
Output for 5.6.16
AAA-BAN025
Output for 5.6.15
AAA-YEK045
Output for 5.6.14
AAA-NHH700
Output for 5.6.13
AAA-TTJ953
Output for 5.6.12
AAA-NBT287
Output for 5.6.11
AAA-ZTU493
Output for 5.6.10
AAA-YJD126
Output for 5.6.9
AAA-ALH794
Output for 5.6.8
AAA-DAD471
Output for 5.6.7
AAA-DHG656
Output for 5.6.6
AAA-CBC634
Output for 5.6.5
AAA-GUB777
Output for 5.6.4
AAA-WZH635
Output for 5.6.3
AAA-BXL102
Output for 5.6.2
AAA-KAC629
Output for 5.6.1
AAA-ADQ398
Output for 5.6.0
AAA-MAK000
Output for 5.5.38
AAA-YLT559
Output for 5.5.37
AAA-GYC103
Output for 5.5.36
AAA-JQB953
Output for 5.5.35
AAA-VGX214
Output for 5.5.34
AAA-JCZ910
Output for 5.5.33
AAA-MGA693
Output for 5.5.32
AAA-QTR412
Output for 5.5.31
AAA-CWD360
Output for 5.5.30
AAA-HJH010
Output for 5.5.29
AAA-KSW809
Output for 5.5.28
AAA-UYE400
Output for 5.5.27
AAA-LTU033
Output for 5.5.26
AAA-ETM448
Output for 5.5.25
AAA-YTB729
Output for 5.5.24
AAA-RSC672
Output for 5.5.23
AAA-YQU863
Output for 5.5.22
AAA-FXA675
Output for 5.5.21
AAA-BBY153
Output for 5.5.20
AAA-YSL454
Output for 5.5.19
AAA-PNL382
Output for 5.5.18
AAA-VFJ781
Output for 5.5.16
AAA-DLR416
Output for 5.5.15
AAA-NTV068
Output for 5.5.14
AAA-YNZ826
Output for 5.5.13
AAA-UFU865
Output for 5.5.12
AAA-JCJ500
Output for 5.5.11
AAA-JUU770
Output for 5.5.10
AAA-BUK287
Output for 5.5.9
AAA-FHA413
Output for 5.5.8
AAA-PDW091
Output for 5.5.7
AAA-HTA043
Output for 5.5.6
AAA-SKW356
Output for 5.5.5
AAA-CFW199
Output for 5.5.4
AAA-AXM997
Output for 5.5.3
AAA-KLB686
Output for 5.5.2
AAA-BPF058
Output for 5.5.1
AAA-STN751
Output for 5.5.0
AAA-MNL667
Output for 5.4.45
AAA-MDU438
Output for 5.4.44
AAA-PRK435
Output for 5.4.43
AAA-SKE572
Output for 5.4.42
AAA-MJV737
Output for 5.4.41
AAA-BWW468
Output for 5.4.40
AAA-TTV048
Output for 5.4.39
AAA-KTP975
Output for 5.4.38
AAA-AYM256
Output for 5.4.37
AAA-ABU688
Output for 5.4.36
AAA-RBT415
Output for 5.4.35
AAA-UWW489
Output for 5.4.34
AAA-VMP243
Output for 5.4.32
AAA-AST268
Output for 5.4.31
AAA-UTP706
Output for 5.4.30
AAA-UDP031
Output for 5.4.29
AAA-BJY795
Output for 5.4.28
AAA-TSV769
Output for 5.4.27
AAA-VXQ488
Output for 5.4.26
AAA-KGK215
Output for 5.4.25
AAA-FSN221
Output for 5.4.24
AAA-YSW902
Output for 5.4.23
AAA-CFL919
Output for 5.4.22
AAA-ADZ593
Output for 5.4.21
AAA-CDG768
Output for 5.4.20
AAA-WYJ138
Output for 5.4.19
AAA-ZGH729
Output for 5.4.18
AAA-PTL093
Output for 5.4.17
AAA-HYD409
Output for 5.4.16
AAA-NQJ122
Output for 5.4.15
AAA-FPB867
Output for 5.4.14
AAA-PXK008
Output for 5.4.13
AAA-TCH815
Output for 5.4.12
AAA-CGN668
Output for 5.4.11
AAA-FYG782
Output for 5.4.10
AAA-HYZ612
Output for 5.4.9
AAA-REX344
Output for 5.4.8
AAA-RKP086
Output for 5.4.7
AAA-LQD358
Output for 5.4.6
AAA-NWT773
Output for 5.4.5
AAA-NDU779
Output for 5.4.4
AAA-PPW308
Output for 5.4.3
AAA-LCR041
Output for 5.4.2
AAA-KHA193
Output for 5.4.1
AAA-SEW306
Output for 5.4.0
AAA-JZZ949
Output for 5.3.29
AAA-FDK257
Output for 5.3.28
AAA-HXV236
Output for 5.3.27
AAA-TXN383
Output for 5.3.26
AAA-FHX655
Output for 5.3.25
AAA-YZQ121
Output for 5.3.24
AAA-SBA763
Output for 5.3.23
AAA-RRB910
Output for 5.3.22
AAA-UBX227
Output for 5.3.21
AAA-QUM384
Output for 5.3.20
AAA-SNL866
Output for 5.3.19
AAA-VVC193
Output for 5.3.18
AAA-JEV698
Output for 5.3.17
AAA-MFE258
Output for 5.3.16
AAA-ZHE792
Output for 5.3.15
AAA-ATZ320
Output for 5.3.14
AAA-PSF061
Output for 5.3.13
AAA-GEF037
Output for 5.3.12
AAA-BKM993
Output for 5.3.11
AAA-JSU392
Output for 5.3.10
AAA-ZAK983
Output for 5.3.9
AAA-CKW414
Output for 5.3.8
AAA-GLN751
Output for 5.3.7
AAA-CUX041
Output for 5.3.6
AAA-QZG314
Output for 5.3.5
AAA-CRB897
Output for 5.3.4
AAA-XYE532
Output for 5.3.3
AAA-EDV525
Output for 5.3.2
AAA-MAM528
Output for 5.3.1
AAA-CFR333
Output for 5.3.0
AAA-CHZ226
Output for 5.2.17
AAA-ZCY276
Output for 5.2.16
AAA-WLZ010
Output for 5.2.15
AAA-HRB960
Output for 5.2.14
AAA-KKJ918
Output for 5.2.13
AAA-XKS840
Output for 5.2.12
AAA-NLJ808
Output for 5.2.11
AAA-ALE451
Output for 5.2.10
AAA-CDD553
Output for 5.2.9
AAA-GQZ231
Output for 5.2.8
AAA-PDY213
Output for 5.2.7
AAA-MXU108
Output for 5.2.6
AAA-FXV431
Output for 5.2.5
AAA-JSZ509
Output for 5.2.4
AAA-DDN358
Output for 5.2.3
AAA-APX281
Output for 5.2.2
AAA-TZJ074
Output for 5.2.1
AAA-LKH878
Output for 5.2.0
AAA-KHY663
Output for 5.1.6
AAA-ADX378
Output for 5.1.5
AAA-DBQ972
Output for 5.1.4
AAA-TQM154
Output for 5.1.3
AAA-JQW014
Output for 5.1.2
AAA-XJN182
Output for 5.1.1
AAA-KBD549
Output for 5.1.0
AAA-TYG517
Output for 5.0.5
AAA-AEJ916
Output for 5.0.4
AAA-BXT585
Output for 5.0.3
AAA-TMV487
Output for 5.0.2
AAA-GLS802
Output for 5.0.1
AAA-GSP394
Output for 5.0.0
AAA-UFD373
Output for 4.4.9
AAA-AML258
Output for 4.4.8
AAA-QMM976
Output for 4.4.7
AAA-HTC449
Output for 4.4.6
AAA-GFH910
Output for 4.4.5
AAA-YEY741
Output for 4.4.4
AAA-NBL182
Output for 4.4.3
AAA-ZFQ641
Output for 4.4.2
AAA-DSV057
Output for 4.4.1
AAA-QUK944
Output for 4.4.0
AAA-RZU251
Output for 4.3.11
AAA-PDZ156
Output for 4.3.10
AAA-TAY780
Output for 4.3.9
AAA-FUD517
Output for 4.3.8
AAA-PXV018
Output for 4.3.7
AAA-DLD151
Output for 4.3.6
AAA-KMU349
Output for 4.3.5
AAA-AKS272
Output for 4.3.4
AAA-BHQ451
Output for 4.3.3
AAA-SFP884
Output for 4.3.2
AAA-XSF480
Output for 4.3.1
AAA-ZCL813
Output for 4.3.0
AAA-CZR923