由于某些原因,即使$jobList[1]
和$titlesearch
的值相同,我也无法通过strpos来搜索数组...很抱歉,虽然很明显,但我仍然很漂亮编码新手!
我从我的$data
数组开始,如下所示:
Array
(
[0] => P0001 Lifeguard descexample 18/09/18 parttime fixedterm mail vic
[2] => P0002 IT Manager descexample 18/09/18 fulltime ongoing post mail sa
)
然后我将这些条目中的每一个爆炸到它们自己的数组中...
for ($i = 0; $i < count($data); $i++) {
$jobList = explode("\t", $data[$i]);
}
Array
(
[0] => P0001
[1] => Lifeguard
[2] => descexample
[3] => 18/09/18
[4] => parttime
[5] => fixedterm
[6] =>
[7] => mail
[8] => vic
)
Array
(
[0] => P0002
[1] => IT Manager
[2] => descexample
[3] => 18/09/18
[4] => fulltime
[5] => ongoing
[6] => post
[7] => mail
[8] => sa
)
现在,我正在尝试从用户输入$titlesearch
中搜索这些数组,并发现它们与职位$jobList[1]
相匹配:
if (strpos($jobList[1], $titlesearch)) {
echo "nice one";
}
无论我尝试什么循环,strpos
都不会返回true,即使我回显这些值并且它们都给出相同的结果,所以我真的不确定我在做什么错了:'(
非常感谢您的帮助!
答案 0 :(得分:1)
使用此函数时,应始终比较数据类型,因为它可能不会返回布尔值,并且可能会误导用户。 Check documentation here
尝试这样的事情:
This is circle and its content: Custom Circle content
This is line and its content: Custom Line content