php for for if dash left 50 89 128 top 39 76 114 imagecopyresampled ba

 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
<?php
for ($y = 0; $y < 3; ++$y) {
for ($x = 0; $x < 3; ++$x) {
if($dash[$x][$y]){
$left = [
0 => 50,
1 => 89,
2 => 128,
];
$top = [
0 => 39,
1 => 76,
2 => 114,
];
imagecopyresampled($basis, imagecreatefrompng('../public/images/areas/'.$dash[$x][$y].'.png'), $left[$y], $top[$x], 0, 0, 34, 34, 34, 34);
}
}
}
?>
Было:
for ($y = 0; $y < $size[0]; ++$y) {
for ($x = 0; $x < $size[1]; ++$x) {
if($dash[$x][$y]){
if($x == 0 & $y == 0) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 50, 39, 0, 0, 34, 34, 34, 34);
elseif($x == 1 & $y == 0) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 89, 39, 0, 0, 34, 34, 34, 34);
elseif($x == 2 & $y == 0) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 128, 39, 0, 0, 34, 34, 34, 34);
elseif($x == 0 & $y == 1) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 50, 76, 0, 0, 34, 34, 34, 34);
elseif($x == 1 & $y == 1) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 89, 76, 0, 0, 34, 34, 34, 34);
elseif($x == 2 & $y == 1) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 128, 76, 0, 0, 34, 34, 34, 34);
elseif($x == 0 & $y == 2) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 50, 114, 0, 0, 34, 34, 34, 34);
elseif($x == 1 & $y == 2) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 89, 114, 0, 0, 34, 34, 34, 34);
elseif($x == 2 & $y == 2) imagecopyresampled($basis, imagecreatefrompng('images/areas/'.$dash[$x][$y].'_'.$dash[$x][$y].'.png'), 128, 114, 0, 0, 34, 34, 34, 34);
}
}
}