【发布时间】:2014-04-14 17:52:37
【问题描述】:
试图让这段代码工作。显示我正在尝试做什么以及缺少什么可能会更容易:
<?php
$array=array(
"something",
"something else"
);
/*pick a random entry in the array and store it as $output*/;
if(strpos($output,"else") !== false){
//do stuff;
}
echo "<div>";
echo $output
echo "</div>"
?>
如您所见,我在尝试将随机条目存储在 $output 中时遇到问题。我要做的是从数组中选择一个随机条目,如果满足条件,对结果运行 strpos 以执行其他操作,然后在 div 之间输出相同的随机条目。
编辑:如果不清楚,用/* 和*/ 注释的行应该是“填充空白”行,而不是“此注释指的是下面的代码行”注释.
【问题讨论】: