|
Posted by Jasen Betts on 02/07/06 10:25
On 2006-02-07, giloosh <giloosh99@gmail.com> wrote:
> Hello,
> I am having trouble getting the strrpos from a file on a linux machine.
>
> someone says it has something to do with binary?
> The code works fine on windows, but when i run it on a linux server it
> gives me a different result
>
> heres an examples:
><?
> $haystack= file_get_contents("mysite.com");
>
> $needle = "blabla";
>
> $x = strrpos($haystack, $needle);
>
> echo $x
>
> //$x returns 201 on windows
> //$x returns 300 on linux
> ?>
>
> Any ideas?
windows translates "\r\n" to "\n" when reading text files. If your mysite.com
file (bad name for a text file on windows) has 99 (very short) lines before
the last occurrance of "blabla" that would explain it.
easiest fix:
$haystack= preg_replace("/\r\n/","\n",file_get_contents("mysite.com"));
Bye.
Jasen
Navigation:
[Reply to this message]
|