Forum Moderators: coopster

Message Too Old, No Replies

strrpos problem on Windows with IIS

problem is due to forward slash

         

TechMan

6:50 am on Sep 24, 2008 (gmt 0)

10+ Year Member



Hi,

When I run the following code on Apache on Windows:


$string = "<body><new></new><tr><td>dfdfdfdfdf</td></tr><content>Sdsdfdfdfd</content></body>";

print strrpos($string,"</tr>");

It returns 40.

But when I run the same code on IIS on Windows it returns 74. The problem is due to the / with tr.
I tried using // and \/ to escape but didn't work. How do I make it work?

Thanks

MattAU

8:21 am on Sep 24, 2008 (gmt 0)

10+ Year Member



This isn't an IIS problem, it's a PHP version problem.

Strrpos in PHP4 only takes a single character to search for, not a string. If you enter a string it'll just search for the first character of that string. Which in your example is '<' which is at position 74.

To get it to work upgrade to PHP5 or use something different to strrpos.

TechMan

9:08 am on Sep 24, 2008 (gmt 0)

10+ Year Member



Oh yes and this is also mentioned @ php.net/strrpos which I over looked. Thanks.