Forum Moderators: coopster

Message Too Old, No Replies

Baffling strpos problem

         

lorax

7:04 pm on Nov 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I need to locate the first occurence of a string within an article. The string is in the format of 'B is for beer'. the code I'm using is:

strpos($copy, $var[string])

$copy is an article for which I have applied the following to:

$copy = str_replace($var[string], $ital, $article[copy]);

This line simply brackets every instance of the $var[string] with <i></i>.

Combined all the code works fine for all of the other articles but chokes on just one. I suspect it has something to do with the format of the string but I can't see why. I must be missing something obvious but what?

Distel

7:21 pm on Nov 22, 2003 (gmt 0)

10+ Year Member



Have you tried escaping these strings [addslashes()]?

lorax

8:08 pm on Nov 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On the output I strip the slashes but I don't think that's the issue. The other 50 articles (with characters that need excaping) work fine.

Aha! I found the culprit. The string I'm using to search the copy has a capital 'I' in the word is - while the copy uses a lowercase 'i'. I knew it had to be something silly. Thanks for listening.