Voucher Code Generator - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Voucher Code Generator.php
- <?php
- $row = 10; //total row of code
- $length = 8; //length of code
- function code_generator($row, $length)
- {
- for($i=0; $i<$row; $i++)
- {
- $part1 = md5( $i.mt_rand() );
- $part1 = preg_replace('/^(.{'.($length-2).'}).*/', '$1', $part1);
- $part2 = preg_replace('/.*(.{2})$/', '$1', uniqid());
- $code = $part1.$part2;
- print $code;
- print "\n";
- }
- }
- print "\n";
- code_generator($row, $length);