amedio
asked on
Find String in an HTML
Anybody knows how can i find the words in the string with another function for avoid regular expression use?
Thanks a lot.
Thanks a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 = '/^(?:\s| )+|(?:\s|&n
$string = preg_replace($pattern, '', $element->plaintext);
$pattern = '/^( )+/';
$string = preg_replace($pattern, '', $string);
if ($string != 'Datos Técnicos')
{
echo 'NO' . '<br>';
}
else
{
echo 'YES' . '<br>';
}
}