-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.php
More file actions
26 lines (21 loc) · 697 Bytes
/
test.php
File metadata and controls
26 lines (21 loc) · 697 Bytes
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
<?php
date_default_timezone_set('Europe/Berlin');
function getUnitImageByName($unitname) {
$image = "Generic.png";
$dir = 'images/units/';
$files = glob($dir.'*.png');
foreach ($files as &$img) {
$imagenametrimmed = basename(strtolower(str_replace(' ', '', trim($img))), ".png");
$imagename = basename(str_replace(' ', '', trim($img)));
$unitnametrimmed = strtolower(str_replace(' ', '', trim($unitname)));
echo $imagenametrimmed." | ".$unitnametrimmed."<br>";
if (strpos($unitnametrimmed, $imagenametrimmed) !== false) {
$image = $imagename;
break;
}
}
echo "Found: ".$image;
return $image;
}
$name = getUnitImageByName("Vulture (Mad Dog) G");
?>