Ejemplo n.º 1
0
 case "Date":
     // convert the From and To dates to datetimes
     list($month, $day, $year) = split("/", $col[2][1]);
     $from_date = mktime(0, 0, 0, $month, $day, $year);
     list($month, $day, $year) = split("/", $col[2][2]);
     $to_date = mktime(0, 0, 0, $month, $day, $year);
     // randomly pick a date between those dates
     $rand_date = mt_rand($from_date, $to_date);
     // display the new date in the value specified
     $row_vals[] = date($col[2][0], $rand_date);
     break;
 case "Text-Fixed":
     $row_vals[] = generate_random_text_str($g_words, false, "fixed", $col[2][0]);
     break;
 case "Text-Random":
     $row_vals[] = generate_random_text_str($g_words, $col[2][2], "range", $col[2][0], $col[2][1]);
     break;
 case "Auto-Increment":
     $start = $col[2][0];
     $increment = $col[2][1];
     $row_vals[] = ($row - 1) * $increment + $start;
     break;
 case "List":
     $elements = explode("|", $col[2][2]);
     if ($col[2][0] == "Exactly") {
         $row_vals[] = join(", ", return_random_subset($elements, $col[2][1]));
     } else {
         // At MOST. So randomly calculate a number up to the num specified:
         $num_items = rand(0, $col[2][1]);
         $row_vals[] = join(", ", return_random_subset($elements, $num_items));
     }
Ejemplo n.º 2
0
 case "Date":
     // convert the From and To dates to datetimes
     list($month, $day, $year) = split("/", $col[2][1]);
     $from_date = mktime(0, 0, 0, $month, $day, $year);
     list($month, $day, $year) = split("/", $col[2][2]);
     $to_date = mktime(0, 0, 0, $month, $day, $year);
     // randomly pick a date between those dates
     $rand_date = mt_rand($from_date, $to_date);
     // display the new date in the value specified
     $elements[] = date($col[2][0], $rand_date);
     break;
 case "Text-Fixed":
     $elements[] = generate_random_text_str($g_words, false, "fixed", $col[2][0]);
     break;
 case "Text-Random":
     $elements[] = generate_random_text_str($g_words, $col[2][2], "range", $col[2][0], $col[2][1]);
     break;
 case "Auto-Increment":
     $start = $col[2][0];
     $increment = $col[2][1];
     $elements[] = ($row - 1) * $increment + $start;
     break;
 case "List":
     $all_elements = explode("|", $col[2][2]);
     if ($col[2][0] == "Exactly") {
         $elements[] = join(", ", return_random_subset($all_elements, $col[2][1]));
     } else {
         // At MOST. So randomly calculate a number up to the num specified:
         $num_items = rand(0, $col[2][1]);
         $elements[] = join(", ", return_random_subset($all_elements, $num_items));
     }
Ejemplo n.º 3
0
 case "Date":
     // convert the From and To dates to datetimes
     list($month, $day, $year) = split("/", $col[2][1]);
     $from_date = mktime(0, 0, 0, $month, $day, $year);
     list($month, $day, $year) = split("/", $col[2][2]);
     $to_date = mktime(0, 0, 0, $month, $day, $year);
     // randomly pick a date between those dates
     $rand_date = mt_rand($from_date, $to_date);
     // display the new date in the value specified
     echo date($col[2][0], $rand_date);
     break;
 case "Text-Fixed":
     echo generate_random_text_str($g_words, false, "fixed", $col[2][0]);
     break;
 case "Text-Random":
     echo generate_random_text_str($g_words, $col[2][2], "range", $col[2][0], $col[2][1]);
     break;
 case "Auto-Increment":
     $start = $col[2][0];
     $increment = $col[2][1];
     echo ($row - 1) * $increment + $start;
     break;
 case "List":
     $elements = explode("|", $col[2][2]);
     if ($col[2][0] == "Exactly") {
         echo join(", ", return_random_subset($elements, $col[2][1]));
     } else {
         // At MOST. So randomly calculate a number up to the num specified:
         $num_items = rand(0, $col[2][1]);
         echo join(", ", return_random_subset($elements, $num_items));
     }
Ejemplo n.º 4
0
function generate_street_address($words)
{
    $street_address = "";
    $street_name = ucwords(generate_random_text_str($words, false, "fixed", 1));
    $valid_str_types = array("St.", "St.", "Street", "Road", "Rd.", "Rd.", "Ave", "Av.", "Avenue");
    $street_type = $valid_str_types[rand(0, count($valid_str_types) - 1)];
    $format = rand(1, 4);
    switch ($format) {
        case "1":
            $street_address = "P.O. Box " . rand(100, 999) . ", " . rand(100, 9999) . " {$street_name} " . $street_type;
            break;
        case "2":
            $street_address = rand(100, 999) . "-" . rand(100, 9999) . " {$street_name} " . $street_type;
            break;
        case "3":
            $street_address = "Ap #" . rand(100, 999) . "-" . rand(100, 9999) . " {$street_name} " . $street_type;
            break;
        case "4":
            $street_address = rand(100, 9999) . " {$street_name} " . $street_type;
            break;
    }
    return $street_address;
}