Find match of string if only at end of string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

I'm trying to compare two strings in order to determine whether or not
the site is just switching languages on the same page or whether the
link is pointing to an entirely different page.  Things were fine
until I realized I was getting false positives for subpages, where the
URLs matched.

Previous code example:

if (strpos('http://domain.com/fr/about/page/', '/about/page/') > -1){
    $same_page = true;
}

As you can see this logic is not strong enough to deal with:

if (strpos(http://domain.com/about/page/subpage/', '/about/page/') > -1){
    $same_page = true;
}

As it is not the same page.  I've looked into strrpos() and tried to
use the negative offset as the length of the needle, but unfortunately
it searches backwards from the offset and not forwards.  Any ideas?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux