我有一個文本文件的顏色。如果選擇了橙色,該腳本僅返回true。我錯過了什麼?簡單的PHP腳本奇怪的回報
$filename="colors.txt";
$words=file($filename);
shuffle($words);
$word=$words[0];
if ($word == "yellow"){$pid = '558';}
else if ($word == "red"){$pid = '557';}
else if ($word == "purple"){$pid = '556';}
else if ($word == "orange"){$pid = '555';}
else if ($word == "green"){$pid = '554';}
else if ($word == "brown"){$pid = '553';}
else if ($word == "blue"){$pid = '552';}
else {$pid = 'poop';}
echo $word;
echo $pid;
爲colors.txt
red
green
blue
yellow
brown
purple
orange
Got it!多謝你們! – 2012-04-17 22:10:43
@Justin,我相信寫回答的人會喜歡它,如果你接受:-) – Dale 2012-04-17 22:22:16
大聲笑,我迷路了代碼。當我點擊更早接受答案時說,我不得不等待4分鐘。然後我失去了時間的蹤跡。 – 2012-04-17 22:51:56