Q:

Replacing piece of string when scraping with SimpleHTMLDom

Using: http://simplehtmldom.sourceforge.net/
I'm comparing prices of pretty much the same products of different brands. Now, when I'm getting info from a  tag, the weight is already included, I want to get rid of that part and write the weight myself, as I will be putting all the info in a table.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Supplementen Prijzenvergelijking</title>
</head>
<body>
<?php
include("simple_html_dom.php");
// DOM object creeëren
$html = new simple_html_dom();
// HTML ophalen
$html->load_file('http://bodyenfitshop.nl/whey-proteine/body-fit-sportsnutrition/whey-perfection');

$wp22kg = $html->find(".r", 2)->innertext;
$wp44kg = $html->find(".r", 4)->innertext;

// Prijs ophalen van B&F Shop Whey Perfection dmv innertext van <td class=r>
echo "Whey Perfection 2270 gram: " . $wp22kg . "<br>";
echo "Whey Perfection 4540 gram: " . $wp44kg . "<br>";

// HTML ophalen
$html->load_file('http://www.xxlnutrition.nl/whey-delicious/xxl-nutrition');

$wd25kg = $html->find('option[value=437]', 0)->innertext;

// Prijs ophalen van XXL Nutrition Whey Delicious dmv <option value=*>
echo "Whey Delicious " . $wd25kg;
?>
</body>
</html>

This is the output:
Whey Perfection 2270 gram: € 32,90
Whey Perfection 4540 gram: € 54,90
Whey Delicious 2500 gram » € 49.95

I would like to replace “2500 gram » ”, how do I do it ? I've tried str_ireplace and preg_replace but couldn't get it working, output was left unchanged.
Note: I'm an amateur.

A:

Oh, I've solved it. I had to use a backslash with preg_replace(); and had to write the special character “the special way”.
<?php
// HTML ophalen
$html->load_file('http://www.xxlnutrition.nl/whey-delicious/xxl-nutrition');
$html = preg_replace('/2500 gram &raquo; /', '', $html);
$html = str_get_html($html);

$wd25kg = $html->find('option[value=437]', 0)->innertext;

// Prijs ophalen van XXL Nutrition Whey Delicious dmv <option value=*>
echo "Whey Delicious 2500 gram: " . $wd25kg;
?>

