-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLicensePlateLib.php
70 lines (57 loc) · 2.02 KB
/
LicensePlateLib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace lugges\LPL;
// Copyright (c) 2020 Lukas Adrian Kron
class LicensePlateLib
{
// ######################################################################### Germany ######################################################################### //
public function generateGermanLicensePlate($region = null, $city = null) {
include("license-plates.php");
if ($region == null) {
$region = array_rand($GermanLicensePlates);
}
if ($city == null) {
$city = array_rand($GermanLicensePlates[$region]);
}
$FirstLetter = substr($GermanLicensePlateLetters, random_int(1, 25), 1);
$SecondLetter = substr($GermanLicensePlateLetters, random_int(1, 25), 1);
$Length = random_int(1, 2);
if ($Length == 1) {
$Letters = $FirstLetter;
} else {
$Letters = $FirstLetter.$SecondLetter;
}
$cityLength = strlen($city);
$LettersLength = strlen($Letters);
$TotalLength = $cityLength + $LettersLength;
if ($TotalLength > 4 ) {
$Number = random_int(1, 999);
} else {
$Number = random_int(1, 9999);
}
echo $city." ".$Letters." ".$Number;
}
public function generateGermanArmyPlate() {
echo "Y ".random_int(100, 999)." ".random_int(100, 999);
}
public function generateGermanWaterPlate() {
echo "BW ".random_int(1, 6)." ".random_int(111, 999);
}
public function searchPrefix($code) {
include("license-plates.php");
foreach ($GermanLicensePlates as $GLP){
foreach ($GLP as $key => $value){
if($key == $code)
echo "$value";
}
}
}
// ######################################################################### Spain ######################################################################### //
public function generateSpanishLicensePlate() {
include("license-plates.php");
$FirstLetter = substr($SpanishLicensePlateLetters, random_int(1, 19), 1);
$SecondLetter = substr($SpanishLicensePlateLetters, random_int(1, 19), 1);
$ThirdLetter = substr($SpanishLicensePlateLetters, random_int(1, 19), 1);
echo random_int(1000, 9999)." ".$FirstLetter.$SecondLetter.$ThirdLetter;
}
}
?>