I have an entire HTML page inside one variable ($product_info) and I am trying to get the following values into seperate variables
<h1 itemprop="name">Product name</h1>
<span id="prvat">£285.60</span>
<span id="spc">142020EB</span>
I am trying to use the following php code, but it's simply not outputting the expected result
$product_info =
('
<h1 itemprop="name">Product name</h1>
<span id="prvat">£285.60</span>
<span id="spc">142020EB</span>
');
$product_name = preg_match('/<h1 itemprop="name">(.*)<\/h1>/', $product_info);
$price = preg_match('/<span id="prvat">(.*)<\/span>/', $product_info);
$product_code = preg_match('/<span id="spc">(.*)<\/span>/', $product_info);
echo ("Product Name = ".$product_name."<br>Price = ".$price."<br>Product Code = ".$product_code);
This is the output
Product Name = 1
Price = 1
Product Code = 1
Can someone point me in the right direction please.