php checking if the last character is a '/' if not then tack it on
<p>I have these 2 snippets of code that I have been playing with, but can't seem to get the logic to stick in either of them.</p>

<p>I am trying to see if a given string has a '/' at the end, if not then add it.</p>

<p><code>$path = '.';</code></p>

<pre><code>if (substr($path, 0, -1) != '/')
    $path .= '/';
</code></pre>

<p>and</p>

<pre><code>if (strrpos('/', $path) !== true)
    $path .= '/';
</code></pre>

<p>the issue im having is that if i make <code>$path</code> equal to <code>'./</code> then I get this as the output <code>.//</code></p>

<p>this is the snippet of where i am having the issue</p>

<pre><code>if (!is_array($paths))
    $this-&gt;classPath[] = $paths;
else
    $this-&gt;classPath = $paths;

foreach ($this-&gt;classPath as $path) {

    if (strrpos('/', $path) !== true)// || substr_count($path, '/') &gt;= 0)
        $path = $path . '/';
    //else
        //$this-&gt;classPath[] = $path;
        //echo '0';
    $pathArr[] = $path;
</code></pre>
