Hello, I have a string of data called $data. Inside of this string are html links in the format of <a ...... >. I need a way to pull out every link that is in the string and load it into an array. I made this code here but it doesnt seem to work. Any ideas?
$data = htmlentities($data);
parseLinks($data);
function parseLinks ($data) {
if(strstr($data,'<a')) {
$start = strpos($data, '<a');
$comment = strstr($data, '<a');
$length = strpos($comment, '->') + 2;
$pageLink[] = $comment;
$data = substr_replace($data, '', $start, $length);
// recursive function so that it continues removing comments untill there are none left.
$data = parseLinks ($data);
return $pageLink;
} else {
return $pageLink;
}
}