How can I make my function work with my if statement that changes my array
<p>In the script below I have an array. My array stores all the links, titles and descriptions from a web page. But I want to make sure that if there is no description, it will use the first 20 characters of a p tag using a function which works. Only problem is I have the jigsaw pieces and just can't seem to put them together, So I want my if statement to show that if the description is empty to use the function getWord instead of <code>getMetas()</code>.</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];   
    }
  }
}
</code></pre>

<p>Then my function goes here (<code>get_custom_excert</code>), but there is no need to see that as I know that works.</p>

<pre><code>function getWord() {
  $html = file_get_contents($link);    
  preg_match('%(&lt;p[^&gt;]*&gt;.*?&lt;/p&gt;)%i', $html, $re);
  $res = get_custom_excerpt($re[1]);
}

$outputs = array();

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

  if ($output['description'] == null) {
  $output['description'] = getWord($res);
  }

  $outputs[] = $output;
}

print_r($output);
</code></pre>
