note 53806 deleted from function.trim by mazzanet

From: Date: Tue, 14 Jun 2005 05:38:56 +0000
Subject: note 53806 deleted from function.trim by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90390@lists.php.net to get a copy of this message
Note Submitter: bpgordon at gmail dot com Reason: useless ---- Moderator, you deleted the wrong one! This is the right one. 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 = str_split($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 (#90390) next »