Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Generating Random Names With PHP

This is a short tutorial on how to generate random names with PHP. With PHP you can automatically generate random name using this script.

In this example, we have two PHP arrays. One contains a list of common names. The other contains a list of common surnames. Using the function mt_rand.

PHP


Demo

<?php
$names = array(
    'Hardik',
    'Shivam',
    'Nirmal',
    'Kaushik',
    'Pradip',
    'Rixit',
    'Neel',
    'Samantha',
);
 
//PHP array containing surnames.
$surnames = array(
    'Patel',
    'Thompson',
    'Anderson',
    'Johnson',
    'Tremblay',
    'Peltier',
    'Cunningham',
    'Simpson',
    'Mercado',
    'Sellers'
);
 
//Generate a random name.
$random_name = $names[mt_rand(0, sizeof($names) - 1)];
 
//Generate a random surname.
$random_surname = $surnames[mt_rand(0, sizeof($surnames) - 1)];
 
//Combine them together and print out the result.
echo $random_name . ' ' . $random_surname;
?>



Please support us, Like us on Facebook.

0 comments:

Post a Comment

 

Copyright @ 2017 HKBlog.