Posted on 2011-03-08
Hi, i´m trying to searh a couple of words in a String that has been gather from an HTML document file. This code doesn´t work, i think the problem is in the accent (character over the é), anyway i think is better to use some function or expression that searchs the exactly two words in the string, because probably the word "Datos" appears in other part of the HTML...
Thanks a lot for your help.
// the function file_get_html and $element->plaintext is gather from the "Simple HTML DOM" class
$url = "prov.html";
$data = file_get_html($url);
foreach($data->find('a') as $element)
// Regular expressions for clean spaces in the string
$pattern = '/( )+$/';
$string = preg_replace($pattern, '', $element->plaintext);
$pattern = '/^( )+/';
$string = preg_replace($pattern, '', $string);
if ($string != 'Datos Técnicos')
echo 'NO' . '<br>';
echo 'YES' . '<br>';