PHP code example of liorchamla / faker-prices

1. Go to this page and download the library: Download liorchamla/faker-prices library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

liorchamla / faker-prices example snippets



// Adding the provider to Faker
$faker = \Faker\Factory::create();
$faker->addProvider(new Liior\Faker\Prices($faker));

// Using the provider :
echo $faker->price(); // prints 49.99


// Function signature :
$faker->price($min = 1000, $max = 20000, $psychologicalPrice = true, $decimals = true)

// You can cancel the $psychologicalPrice (which gives you credible prices like 29.49 or 119.99 instead of random 23.49 or 102.49)
$faker->price(100, 200, false); // 113.49
$faker->price(100, 200, true); // 109.49

// You can cancel the $decimals also (decimals can be X.29, X.49 or X.99)
$faker->price(100, 200, true, false); // 109
$faker->price(100, 200, true, true); // 109.49