note 89795 deleted from function.substr-count by googleguy

From: Date: Tue, 22 Oct 2013 08:04:13 +0000
Subject: note 89795 deleted from function.substr-count by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196790@lists.php.net to get a copy of this message
Note Submitter: zmindster at gmail dot com ---- 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!

« previous php.notes (#196790) next »