Skip to content

Instantly share code, notes, and snippets.

@farshidrezaei
Created September 7, 2019 18:08
Show Gist options
  • Save farshidrezaei/1ca73e65b4182f0f25bdf4f0387c41ad to your computer and use it in GitHub Desktop.
Save farshidrezaei/1ca73e65b4182f0f25bdf4f0387c41ad to your computer and use it in GitHub Desktop.
Replace Fakers
<?php
//Faker offers a couple of methods that let you replace placeholders in a given string with random characters:
//lexify - takes given string and replaces ? with random letters
//asciify - takes given string and replaces * with random ascii characters
//numerify - takes given string and replaces # with random digits
//bothify - combines the lexify and numerify
//You could try to use one of them, depending on the requirements you have for that random string you need. asciify uses the largest set of characters as replacement so using that one makes most sense.
//The following will give you a random string of 20 ascii characters:
$faker->asciify('********************'); // will give you a random string of 20 ascii characters
$faker->lexify('##########'); // will give you a random string of 10 digits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment