Re: Checking if

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

 



Bruno B B Magalhães wrote:
how to determine if the last char of a string is a '/'...

The problem, a webpage can be accessed by www.domain.com/page.php or www.domain.com/page.php/

Use substr()... http://www.php.net/substr

$url = 'http://example.com/index.php/';

if (strcmp(substr($url, -1), '/') == 0) {
    // it ends with a '/'; strip it off
    $url = substr($url, 0, -1);
}

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com

---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------

--
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