我有一个带有颜色的文本文件。如果选择了橙色,脚本仅返回 true。我到底想念什么?
$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