PHP pathinfo gets fooled by url in quert string. Any workaround?
<p>I am working on a small function to take in a url and return a relative path based on where it resides itself.</p>

<p>If the url contains a path in the query string, <code>pathinfo</code> returns incorrect results. This is demonstrated by the code below:</p>

<pre><code>$p = 'http://localhost/demos/image_editor/dir_adjuster.php?u=http://localhost/demos/some/dir/afile.txt';
$my_path_info = pathinfo($p);
echo $p . '&lt;br/&gt;&lt;pre&gt;';
print_r($my_path_info);
echo '&lt;/pre&gt;';
</code></pre>

<p>That code outputs:</p>

<pre><code>http://localhost/demos/image_editor/dir_adjuster.php?u=http://localhost/demos/some/dir/afile.txt

Array
(
    [dirname] =&gt; http://localhost/demos/image_editor/dir_adjuster.php?u=http://localhost/demos/some/dir
    [basename] =&gt; afile.txt
    [extension] =&gt; txt
    [filename] =&gt; afile
)
</code></pre>

<p>Which obviously is wrong. Any workaround?</p>
