0

So, I have a website in which I gather data directly from another associated website, in order to display information. To do this, I am fetching the website (using file_get_contents) and stripping out anything not relevant using eregi. My problem is that even though I've done thourough research on how to convert this eregi to a not deprecated preg_match, I can not seem to find a solution.

Anyone bright enough to understand the complexities of preg_match?

Here's my current code:

$content = file_get_contents("http://www.vattenfall.se/sv/teckna-   elavtal.htm/papp/mac:24432/ma-vf_se-orderflow/ProductSelection.action?orderMode=true&submitPostalCode=&orderFlow.personal.postalCode=87140&submitPostalCode=Visa+priser");

eregi('<td style="width: 120px;" class="valuePresentation">(.*)</td>', $content, $data);

foreach($data as $split)
{
    $split = explode("</td>", $split);
}

This works fine - but as I said, the function is deprecated, and I would love to replace it, if only I knew how!

CmdrSharp
  • 1,085
  • 13
  • 30
  • In preg_match() only need add delimiters in regexp pattern – Winston Feb 21 '13 at 21:35
  • Winston's comment is best. in your case the punctuation might need to be escaped. Try: eregi('_(.*)_', $content, $data); Please review mario's link as well. – Lighthart Feb 21 '13 at 21:44

1 Answers1

1
eregi('some expression', $input, $matches);

dark magic, chanting, spooky things...

preg_match('/some expression/i', $input, $matches);

You might want preg_match_all() instead, though.

Sammitch
  • 30,782
  • 7
  • 50
  • 77