I need to know how to iterate through this array and get the html content so that I can use it to make another array. The array I have is this:
$arr = array(
"<span class='inside'>inside1</span> this is outside",
"<span class='inside'>inside2</span> this is outside",
"<span class='inside'>inside3</span> this is outside"
);
and I want the following result:
$result = array(
"inside1",
"inside2",
"inside3"
);
I have tried the following but no results:
foreach ( $arr as $html){
$dom = new DOMDocument();
$dom->loadHTML($html);
$xpath = new DOMXpath($dom);
$result = $xpath->query('//span[@class="inside"]');
echo $result
}
Please Help.