dom nodeValue return value can't be put into a straing

[php]
$aJob = $element2->nodeValue;
echo $aJob.’
’;
$words_aJob = explode(’ ‘, $aJob);
echo count($words_aJob).’
’;
[/php]
the output of $aJob is a sentence I expect to see. The count of $words_aJob is something ridiculous like 150 when there’s only 46 characters in the entire sentence.

All I’m trying to do is display the sentence if it has a certain word at the end.

Using trim helps, now there’s 100 elements when I expect there to be 15.
I could use strpos to check for the last word at the end, but for something else I’m doing I really want to break this into words.

Hi there,

You might be suffering from multiple spaces between words. Try this:
[php]$aJob = trim($element2->nodeValue);
$aJob = preg_replace(’/\s+/’,’ ‘,$aJob);
$words_aJob = explode(’ ', $aJob);
[/php]

Thanks for the reply, I ended up not using explode at all and instead
[php]if(trim($td_elements->item(3)->nodeValue) == ‘Open’)[/php]
I think i was getting screwed up because I was missing the ->item(3) part (since it is an array)…I guess strange things happen when you try to explode an array. I’m not good with this DOM stuff

Sponsor our Newsletter | Privacy Policy | Terms of Service