php-fakerHow can I generate fake money using PHP Faker?
Using PHP Faker library, you can generate fake money using the randomNumber()
method. The method takes two parameters, the first one being the number of digits and the second one being the number of decimal places. For example, the following code will generate a random number with 10 digits and two decimal places:
$faker = Faker\Factory::create();
echo $faker->randomNumber(10,2);
Output example
66.80
The code consists of the following parts:
$faker = Faker\Factory::create();
- This initializes the Faker library.echo $faker->randomNumber(10,2);
- This calls therandomNumber()
method with two parameters (10 digits and 2 decimal places) and prints the output.
Helpful links
More of Php Faker
- How do I generate a zip file using PHP Faker?
- How do I generate a fake year in Laravel using Faker?
- How do I generate a valid VAT number using Laravel Faker?
- How can I generate fake time data using PHP Faker?
- How can I generate fake data in XLSX format using PHP Faker?
- How do I use PHP Faker to generate XML data?
- How can I use Faker with Laravel?
- How do I generate fake state data using PHP Faker?
- How can I generate unique data with Laravel Faker?
- How to generate a title using Laravel Faker?
See more codes...