jp2php Posted July 4, 2009 Share Posted July 4, 2009 I've got a short script that parses a directory. While parsing this directory, I look to see if this is the file I want, using this code snippet: Line 89: $strpos = strpos($file1, $file2, 0); Line 90: if (($strpos !== false) && ($strpos == 0)) { Line 91: echo("Found it!"); Line 92: } The code works, but it posts this warning for every file it encounters during the search: Warning: strpos() [function.strpos]: Empty delimiter in /localhost/test.php on line 89 I know I could simply suppress the warning by using @strpos, but why am I getting this warning? (I did a search online for this first, but it pulled up many, many irrelevant results. Link to comment https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/ Share on other sites More sharing options...
Adika Posted July 4, 2009 Share Posted July 4, 2009 Change this line: if (($strpos !== false) && ($strpos == 0)) { to this one: if ($strpos !== false) { Link to comment https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/#findComment-868884 Share on other sites More sharing options...
jp2php Posted July 4, 2009 Author Share Posted July 4, 2009 It still gives a warning saying that strpos (line 89) has an empty delimiter. What is an empty delimiter? Both $file1 and $file2 have positive lengths. Link to comment https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/#findComment-868888 Share on other sites More sharing options...
Mortekai Posted July 4, 2009 Share Posted July 4, 2009 Sounds like you have a rogue delimiter in those files, like an extra , or something... Could you post line 89 for us? Link to comment https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/#findComment-868894 Share on other sites More sharing options...
jp2php Posted July 4, 2009 Author Share Posted July 4, 2009 Could you post line 89 for us? It's up there in the original post. I found the problem, though. I failed to declare my file being searched for using *global* before passing it to my function. Stupid, newby mistake. Everyone says how similar PHP and C are, then PHP throws me a curve like that! Link to comment https://forums.phpfreaks.com/topic/164769-solved-strpos-empty-delimiter/#findComment-868896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.