This if statement returns no input
<p>I have an array. </p>

<p>In my array is the final piece of my script. My script scans all the links and puts in the array $link. Then it scans all the titles in the $link and then gets all the meta titles of the $link. But then some people don't have meta descriptions, so I decided to create a function which returns 20 characters of a p tag scanned.</p>

<p>Though in my array, my if statement doesn't seem to work. It is supposed to detect if there is any input in the 'description' key in the variable and then use the instructions in the if statement. </p>

<p>However, it doesn't seem to be doing that and I keep thinking I am missing something.</p>

<pre><code>function getMetas($link) {
    $str1 = file_get_contents($link);    

    if (strlen($str1)&gt;0) {
        preg_match_all( '/&lt;meta.*?name=("|\')description("|\').*?content=("|\')(.*?)("|\')/i', $str1, $description);
        if (count($description) &gt; 1) {
            return $description[4];   
        }

    }


}

function get_custom_excerpt($return, $option = 30, $sentance = false) {
    $marks = Array(".","!","?");

    $return = strip_tags($return);

    if($sentance == true) {
        $start = implode(" ", array_slice(preg_split("/\s+/", $return), 0, $option ));
        $start .= ' ';
        $end = implode(" ", array_slice(preg_split("/\s+/", $return), $option));

        $cut = Array();
        foreach($marks AS $m =&gt; $mark){
            $mark = strpos($end, $mark);
            if($mark != false) $cut[$m] = $mark;
        }

        if($cut[0] != "")
            $chop = min($cut);
        else
            $chop = $option;
        $rest = substr($end, 0, $chop);

        $key = array_search($chop, $cut);

        $return = $start.$rest;

    }else{
        $return = implode(" ", array_slice(preg_split("/\s+/", $return), 0, $option));
    }
    $return .= $marks[$key];

    return $return; 
}     


$html = file_get_contents($link);    
preg_match('%(&lt;p[^&gt;]*&gt;.*?&lt;/p&gt;)%i', $html, $re);
$res = get_custom_excerpt($re[1]);


$out = Array();

foreach ($links as $thisLink) {
    $out = array("link" =&gt; $thisLink, "title" =&gt; Titles($thisLink), "description" =&gt; getMetas($thisLink));

    if (empty($out['description'])) {
        $out['description'] = $res;
    }

    $output[] = $out;

}
</code></pre>

<p>By the way, the code works perfectly except the if statement. The function has been executed on a smaller array, not the array I am using, and it has returned results to my standard. But it seems to create another key ('description') instead of adding the p tag to it. Any ideas?</p>
