note 89795 added to function.substr-count

From: Date: Mon, 23 Mar 2009 21:53:19 +0000
Subject: note 89795 added to function.substr-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-152349@lists.php.net to get a copy of this message
For some who seeked for an easy way to resolve URL composed of /../ like http://w3.host.tld/path/to/the/file/../../file.extension, here is a solution <?php $url = 'http://w3.host.tld/path/to/file/../file.extension'; while (substr_count($url, "../")) { $url = preg_replace('#/[^/]+/\.\.#', '', $url); } //outputs 'http://w3.host.tld/path/to/file.extension' ?> and seems to work perfectly! ---- Server IP: 64.71.164.2 Probable Submitter: 90.19.9.8 ---- Manual Page -- http://www.php.net/manual/en/function.substr-count.php Edit -- https://master.php.net/note/edit/89795 Del: integrated -- https://master.php.net/note/delete/89795/integrated Del: useless -- https://master.php.net/note/delete/89795/useless Del: bad code -- https://master.php.net/note/delete/89795/bad+code Del: spam -- https://master.php.net/note/delete/89795/spam Del: non-english -- https://master.php.net/note/delete/89795/non-english Del: in docs -- https://master.php.net/note/delete/89795/in+docs Del: other reasons-- https://master.php.net/note/delete/89795 Reject -- https://master.php.net/note/reject/89795 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152349) next »