|
|
|
วานช่วยดูโค้ดให้ทีคะ..พอดีมันไม่สามารถระบุค่าคืนได้คะว่ามันคืนค่าให้ตัวใด แล้วก็ลูปมันวนเกินนะคะ |
|
|
|
|
|
|
|
<?php
$file = fopen("myfile.txt",'r');
$i = 0;
// ========= loop get data ========== //
while(!feof($file)){
$read = fgets($file);
$shirt[$i] = explode(" ",$read);
//print_r ($shirt)."<br>";
//print "<br>";
//print "<br>";
$i++;
}//print "<br>";
fclose($file);
// ============ Define Color_base in Calculate ========= //
// ====== แดง เขียว น้ำเงิน เหลือง ส้มเหลือง ส้ม ส้มแดง ม่วงแดง ม่วง ม่วงน้ำเงิน เขียวน้ำเงิน เขียวเหลือง ====== //
$color_base = array(array("255","0","0"),
array("0","255","0"),
array("0","0","255"),
array("255","255","0"),
array("205","173","0"),
array("238","154","0"),
array("238","118","0"),
array("205","50","120"),
array("128","0","128"),
array("85","26","139"),
array("69","139","116"),
array("173","255","47"));
// print_r ($color_base)."<br>";
//print "<br>";
// =========================================================== Get R G B ============================================================== //
$n=0;
for($i=0;$i<count($shirt)-1;$i++){// R G B ของเสื้อ
$r[$n] = $shirt[$i][2];
$g[$n] = $shirt[$i][3];
$b[$n] = $shirt[$i][4];
$color =array ($r[$n],$g[$n],$b[$n]);
print_r ($color)."<br>";
print "<br>";
$n++;
}print "<br>";
foreach($color as $colors){
foreach($color_base as $value){
$temp[] = array(sqrt(($colors[0]-$value[0])^2+($colors[1]-$value[1])^2+($colors[2]-$value[2])^2));
} //print_r ($temp)."<br>";
} print "<br>";
asort($temp);
print_r ($temp)."<br>";
print "<br>";
?>
Tag : PHP
|
|
|
|
|
|
Date :
2011-04-14 16:44:38 |
By :
sopita16 |
View :
647 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อันนี้คือข้อมูลใน ไฟล์.txt
6 1 177 23 208 3 4 2 1 1 255 3 6
5 2 175 74 253 3 4 1 3 173 130 170
1 2 63 230 214 2 2 1 1 1 3 5 43 205 42 112 7 236 14 205 198 222 82 134 202 51 136 103 133 31 86 138 133
4 2 91 44 224 2 1 1 1 3 2 6 12 179 242 248 194 191 190 160 17 69 106 69 205 210 203 237 41 86
3 3 200 205 235 2 2 1 3 1 1 1 104 21 184 90 14 122 25 205 27 43 18 133 113 224 88 60 205 129 147 64 65
3 1 45 4 110 2 4 3 2 2 2 116 130 174 131 253 200 80 24 243 99 158 101
2 3 162 17 121 1 1 3 2 2 3 2 206 61 90 186 156 36 13 17 167
5 2 164 132 229 3 2 1 2 2 5 83 127 157 204 181 239 134 70 78 110 219 29 172 54 215 73 91 228 90 2 161 239 167 37
5 2 157 29 193 2 3 1 2 1 7 176 53 103 246 132 214 210 161 130 9 120 203 100 93 38 103 254 21 15 36 234
3 3 7 54 61 3 2 1 3 2 232 45 145 223 177 103 178 83 234 188 204 182 32 42 220 136 41 242 152 77 221 12 15 228
2 1 149 141 133 2 3 2 2 1 2 108 176 0 192 155 188 140 81 221 183 46 102 224 32 254
2 3 11 61 226 1 2 2 3 1 1 3 126 192 220 205 45 141 206 237 40 138 122 121
4 2 175 139 41 3 4 2 3 175 215 235
5 2 201 23 65 1 3 3 2 1 3 52 199 68 235 254 128 168 209 24 14 128 163
2 1 125 188 42 1 2 1 3 1 6 1 67 18 7 6 172 118 144 224 61 213 204 60 85 116 13 109 131 141
1 3 219 143 119 1 3 1 1 2 1 249 197 79 12 204 86 184 67 230 153 128 187 101 189 16 218 202 126 93 87 143 24 50 31 143 55 220 153 82 145
|
|
|
|
|
Date :
2011-04-14 16:51:59 |
By :
sopita16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|