function not working on remote server
<p>the function is for checking if an url is pointing to a valid image by checking the meta info in the head section of the given file.</p>

<p>the echo in the below code gives me the correct wrapper data but on my remote server it echoes "ArrayResource id #11"  How this is possible?</p>

<p>local:PHP Version 5.3.4
remote server: PHP Version 5.2.9</p>

<pre><code> function isImage($url)
      {
         $params = array('http' =&gt; array(
                      'method' =&gt; 'HEAD'
                   ));
         $ctx = stream_context_create($params);
         $fp = @fopen($url, 'rb', false, $ctx);
         if (!$fp) 
            return false;  // Problem with url

        $meta = stream_get_meta_data($fp);
        if ($meta === false)
        {
            fclose($fp);
            return false;  // Problem reading data from url
        }

        $wrapper_data = $meta["wrapper_data"];
        if(is_array($wrapper_data)){
          foreach(array_keys($wrapper_data) as $hh){
            echo substr($wrapper_data[$hh], 0, 19);//////////////ECHO////////////////////////
              if (substr($wrapper_data[$hh], 0, 19) == "Content-Type: image") // strlen("Content-Type: image") == 19 
              {
                fclose($fp);
                return true;
              }
          }
        }

        fclose($fp);
        return false;
      }
</code></pre>

<p>EDIT: I adapted the function so it checks if 'Content-Type: image' is somewhere in the header of the file. this works cross server...</p>

<pre><code>function isImage($url)
  {
     $params = array('http' =&gt; array(
                  'method' =&gt; 'HEAD'
               ));
     $ctx = stream_context_create($params);
     $fp = @fopen($url, 'rb', false, $ctx);
     if (!$fp) 
        return false;  // Problem with url

    $meta = get_headers($url);

    if ($meta === false)
    {
        fclose($fp);
        return false;  // Problem reading data from url
    }
    foreach ($meta as $key =&gt; $value) {
        $pos = strpos($value, 'Content-Type: image');
            if($pos!==false){
             fclose($fp);
             return true;
            }
    }



    fclose($fp);
    return false;
  }
</code></pre>
