mkdir() function giving invalid argument error
<p>I'm practicing scraping data from some third party sites with an html parser. While I'm looping thru the given tags, I use the mkdir() function to create a new folder that is named after one of the variables that is being used in the loop. My code is as follows:</p>

<pre><code>foreach($s-&gt;find('a') as $t)
{
    $inner = $t-&gt;plaintext;
    if(!is_dir("img/ncaa/".$team."")
    &amp;&amp; !file_exists("/img/ncaa/".$team."/".substr($inner, 0, 4).".png"))
    {
        foreach($t-&gt;find('img') as $l)
        {
               $url = $l-&gt;src;
        }   

        mkdir("img/ncaa/".$team."");

        $img = "/img/ncaa/".$team."/".substr($inner, 0, 4).".png";
        file_put_contents($img, file_get_contents($url));
    }   
}
</code></pre>

<p>I get an error message reading: <strong>Warning: mkdir() [function.mkdir]: Invalid argument in</strong></p>

<p>When I comment out all of the above code and simply write</p>

<pre><code>mkdir("img/ncaa/Boston Celtics");
</code></pre>

<p>That seems to work. I thought for a bit that it may have had something to do with permissions, but it didn't.</p>

<p>Any suggestions?</p>
