You are here: Re: binary strrpos? « PHP Programming Language « IT news, forums, messages
Re: binary strrpos?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация