note 53803 rejected from function.trim by mazzanet

From: Date: Mon, 13 Jun 2005 22:37:53 +0000
Subject: note 53803 rejected from function.trim by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90381@lists.php.net to get a copy of this message
Note Submitter: bpgordon at gmail dot com ---- Don't use trim to strip the trailing / off of relative URLs! <?php trim($url, "/"); ?> It will also strip the / from the beginning of the URL. Instead, use this function: <?php function trimrelativeurl($url) { $urlarry = explode($url); foreach ($urlarry as $key => $val) { if ($val == "/") $lastslash = $key; } if ($lastslash+1 == strlen($url)) $url = substr($url, 0, strlen($url)-1); return $url; } ?>

« previous php.notes (#90381) next »