PHP Classes

File: examples/simple_people.php

Recommend this page to a friend!
  Classes of Alexander Selifonov   PHP Random people   examples/simple_people.php   Download  
File: examples/simple_people.php
Role: Example script
Content type: text/plain
Description: Using example
Class: PHP Random people
Generate random people names and other data
Author: By
Last change: Update of examples/simple_people.php
Date: 10 months ago
Size: 843 bytes
 

Contents

Class file image Download
<?php
/**
* @name simple_people.php
* Using class.randomdata.php example (make random people list with birthdays)
* @Author Alexander Selifonov, <alex [at] selifan {dot} ru>
* To generate randomized russian people, use parameter "lang" :
* example.php?lang=ru
*
**/
include('../src/class.randomdata.php');
$lang = isset($_GET['lang']) ? $_GET['lang'] : 'en';
include_once(
"../src/class.randomdata.lang-$lang.php");

$sex_arr = array('m', 'f');
for(
$kk=1; $kk<=50; $kk++) {
   
$sex = $sex_arr[rand(0,1)];
   
$ln = RandomData::getLastName($sex);
   
$fn = RandomData::getFirstName($sex);
   
$pn = RandomData::getMiddleName($sex);
   
$birth = RandomData::getRandomDate(4,50, 'm/d/Y');
    echo
"$kk: $ln, $fn $pn, ".decodeSex($sex). ", born: $birth<br>";
}
function
decodeSex($sx) {
    return ( (
$sx === 'f') ? 'female' : 'male');
}
?>
<hr>