Hi there,

Bit of a complicated query, for me anyway. lol

Following code:

$url = 'http://www.cheapsmells.com/viewProduct.php?id=6590';
$html = file_get_contents($url);

preg_match('/<div class=\'productOurPrice\'?>(.+?)(\d+\.\d+)(.+?)?<\/div>/', $html, $match);
$out = $match[2];

Great, no problem!

However, this next url I need to code to is a bit trickier as the tag data is, well see below...

url: http://www.directcosmetics.com/results/products.cfm?ctype=ME&range=Denim&code=14770

tags:

<div class="value">
                                            &pound;1.99 <font size="3"> </font></div>

All the whitespace is confusing me and I can't seem to apply the above to this now.

Any ideas would be very helpful.

PS. It's PHP encased

Recommended Answers

All 2 Replies

Hi there,

Bit of a complicated query, for me anyway. lol

Following code:

$url = 'http://www.cheapsmells.com/viewProduct.php?id=6590';
$html = file_get_contents($url);

preg_match('/<div class=\'productOurPrice\'?>(.+?)(\d+\.\d+)(.+?)?<\/div>/', $html, $match);
$out = $match[2];

Great, no problem!

However, this next url I need to code to is a bit trickier as the tag data is, well see below...

url: http://www.directcosmetics.com/results/products.cfm?ctype=ME&range=Denim&code=14770

tags:

<div class="value">
                                            &pound;1.99 <font size="3"> </font></div>

All the whitespace is confusing me and I can't seem to apply the above to this now.

Any ideas would be very helpful.

PS. It's PHP encased

I believe your problem is not the whitespace but the line breaks. You could add checks for \r\n or place a modifier at the end of the regex that treats the line breaks as a single line. I can't really remember what it is exactly, I think its \m or \n.

You could try using the PHP trim() function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.