I am trying get the string structure produced between a <span>
element when it includes the text "Bonkers".
For example:
<span> Bonkers </span>
or
<span> Bonkers </span>
or
<span> Bonkers </span>
The thing is I don't know span structure, but I know "Bonkers" will be in there.
I want to return the entire text string structure (including the < span > open and close tags so that later I can replace it. eg:
$spanwithbonkers = '<span> Bonkers </span>';
So far this is what I have, but it does not work:
<?php
$homepage = file_get_contents('http://www.example.com/');
preg_match('/^<span>^Bonkers^</span>/', $homepage, $matches);
$spanwithbonkers = $matches[0]);
?>
Not sure if preg_match is even supposed to be used.