I have a block of html stored in a custom field in wordpress. I need to return only the links from that custom field using a php function. It must be a function. Here is what i tried, but my result just says array:
<?php
function linkExtractor($html){
$linkArray = array();
if(preg_match_all('/<img\s+.*?src=[\"\']?([^\"\' >]*)[\"\']? [^>]*>/i',$html,$matches,PREG_SET_ORDER)){
foreach($matches as $match){
array_push($linkArray,array($match[1],$match[2]));
}
}
return $linkArray;
}
?>
Within wordpress i use it as a shortcode and it looks like. This is 100% the correct format as i use it all the time.
[linkExtractor(custom_field_name)]