<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: PHP function returns pathname from array of directory names, without duplication&#8230;</title>
	<atom:link href="http://www.dbuggr.com/simon-tite/php-function-returns-pathname-array-directory-names-duplication/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dbuggr.com/simon-tite/php-function-returns-pathname-array-directory-names-duplication/</link>
	<description>Share Knowledge &#38; Be Rewarded</description>
	<lastBuildDate>Wed, 28 Jul 2010 06:02:35 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Simon Tite</title>
		<link>http://www.dbuggr.com/simon-tite/php-function-returns-pathname-array-directory-names-duplication/comment-page-1/#comment-275</link>
		<dc:creator>Simon Tite</dc:creator>
		<pubDate>Sun, 08 Nov 2009 03:30:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.dbuggr.com/simon-tite/php-function-returns-pathname-array-directory-names-duplication/#comment-275</guid>
		<description>This simple PHP function merges an array of directory or file names, to compose a full pathname, if any of the elements of the array contain superfluous directory separators, doubled separators are merged into one.
&lt;code&gt;
    &lt;?php
    function make_path_from_bits() {
        //Accepts $sep (separator, eg &quot;/&quot;), followed by the filenames.
        $bits = func_get_args();    // all the arguments into an array
        $sep = array_shift($bits);  // arg1 is the separator, the rest are the files
        $p = implode($sep,$bits);
        $double = $sep . $sep;
        while (strpos($p,$double) !== false) {
            $p = str_replace($double, $sep, $p);
        }
        return $p;
    }
&lt;/code&gt;
Example of usage:
&lt;code&gt;
$webroot = &quot;/&quot;;
$myfile = &quot;/styles/my.css&quot;;
$data = &quot;data/&quot;

$fullpath = make_path_from_bits(&quot;/&quot;,$webroot,$data,$myfile);
echo $fullpath;
&lt;/code&gt;
...gives the result:
/data/styles/my.css</description>
		<content:encoded><![CDATA[<p>This simple PHP function merges an array of directory or file names, to compose a full pathname, if any of the elements of the array contain superfluous directory separators, doubled separators are merged into one.<br />
<pre><code>
&nbsp;&nbsp;&nbsp;&nbsp;&lt;?php
&nbsp;&nbsp;&nbsp;&nbsp;function make_path_from_bits() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Accepts $sep (separator, eg &quot;/&quot;), followed by the filenames.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$bits = func_get_args();&nbsp;&nbsp;&nbsp;&nbsp;// all the arguments into an array
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sep = array_shift($bits);&nbsp;&nbsp;// arg1 is the separator, the rest are the files
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$p = implode($sep,$bits);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$double = $sep . $sep;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (strpos($p,$double) !== false) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$p = str_replace($double, $sep, $p);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $p;
&nbsp;&nbsp;&nbsp;&nbsp;}
</code></pre><br />
Example of usage:<br />
<pre><code>
$webroot = &quot;/&quot;;
$myfile = &quot;/styles/my.css&quot;;
$data = &quot;data/&quot;

$fullpath = make_path_from_bits(&quot;/&quot;,$webroot,$data,$myfile);
echo $fullpath;
</code></pre><br />
&#8230;gives the result:<br />
/data/styles/my.css</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->