【发布时间】:2017-04-10 07:33:40
【问题描述】:
我试图在 While 循环中过滤一些条目。我正在尝试使用strpos 函数,不幸的是,当我使用变量作为针时,我没有得到结果。
没有结果:
$tra = strpos($HRreq, $entry_type)
结果:$tra = strpos($HRreq, "string");
但是,我需要它在 while 循环中是可变的。
$select_exec = odbc_exec($amos_db,$select_personnel);
while ($row = odbc_fetch_array($select_exec)){
$username = $row['user_sign'];
$entry_type = $row['entry_type'];
$fullname1 = $row['lastname'] . $row['firstname'];
$fullname = trim(preg_replace('/ +/', ' ', preg_replace('/[^A-Za-z0-9 ]/', ' ', urldecode(html_entity_decode(strip_tags($fullname1))))));
$userno = $row['employee_no_i'];
$tra = strpos($HRreq, "$entry_type");
echo $entry_type ." = ". $tra;
}
我添加了部分代码,因为代码长度超过 500 行。我希望这足以让我了解我想要完成的工作
【问题讨论】:
-
能把你用过的代码加进去吗?
-
你确定变量不为空或空白吗?
-
我添加了更多代码,我尝试了
echo$entry_type,然后是$tra,它只返回$entry_type,但$tra为空 -
$HRreq 变量的值是多少?它似乎没有定义。
-
我已经在文件开头设置了,这个变量是相当长的字符串。这么久了,我还没有将它添加到代码中。