Warning: strpos() [function.strpos]: Empty delimiter in foreach statement

淺唱寂寞╮ 提交于 2020-01-05 08:01:09

问题


I have read all topics regarding strpos() issues but I cant find one that will fix mine. So here is the code.

foreach($titles_array as $k=>$v) {
if(strpos($subject,$v) !== false) {
        $i++;
    $asd[$titles['id']] = $i;   
}
}

The script works good and I get the results I'm looking for but this error comes up : Warning: strpos() [function.strpos]: Empty delimiter

I read that it might be an empty string or value in array but I've checked them both and I didnt found any empty string/value. I appreciate any help. All the best !


回答1:


The "empty delimiter" warning occurs when the second parameter to strpos is empty. You definitely have an empty value in $titles_array.

I have reproduced the warning here: http://3v4l.org/RnU3q

Try print_r($titles_array) right before your foreach loop.



来源:https://stackoverflow.com/questions/15824698/warning-strpos-function-strpos-empty-delimiter-in-foreach-statement

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!