【发布时间】:2012-04-17 22:00:33
【问题描述】:
我有一个包含颜色的文本文件。如果选择了橙色,脚本仅返回 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
【问题讨论】:
标签: php wordpress if-statement