I couldn't figure out why there were two loops:
function findurl($redirect_array,$keyword)
{ $matchedurls = array();
foreach($redirect_array as $keyword_url_pair)
if($keyword_url_pair['keyword']==$keyword)
$matched_urls[]=$keyword_url_pair['url'];
return $matched_urls;
}
findurl($redirect_array, 'this is great');
You get an array of URLs with matching keywords. If there is only going to be one URL per possible keyword, it can be simplified and sped up thus:
function findurl($redirect_array,$keyword)
{ $matchedurls = array();
foreach($redirect_array as $keyword_url_pair)
if($keyword_url_pair['keyword']==$keyword)
return$keyword_url_pair['url'];
}
findurl($redirect_array, 'this is great');
This time you get a string instead of an array.