How can i Get Data from using preg_match_all?

<div class="price offerprice bold"> $986.00 </div>

i have 12 different price divs in my html page
i  want to grab all the prices from all matching divs
vishnu kalakotaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Can you please show us a more representative example?  If we can see all 12 divs, we can give you tested and working examples that cover all the cases!
0
vishnu kalakotaAuthor Commented:
<span class="price">
<div class="price offerprice bold"> $986.00 </div>
</span>
0
Julian HansenCommented:
This sample should demonstrate what you need to do
<pre>
<?php

$input = <<< INPUT
<div class="price offerprice bold"> $186.00 </div>
<div class="price offerprice bold"> $286.00 </div>
<div class="price offerprice bold"> $386.00 </div>
<div class="price offerprice bold"> $486.00 </div>
<div class="price offerprice bold"> $586.00 </div>
<div class="price offerprice bold"> $686.00 </div>
<div class="price offerprice bold"> $786.00 </div>
<div class="price offerprice bold"> $886.00 </div>
<div class="price offerprice bold"> $986.00 </div>
<div class="price offerprice bold"> $1086.00 </div>
<div class="price offerprice bold"> $1186.00 </div>
<div class="price offerprice bold"> $1286.00 </div>
INPUT;

$success = preg_match_all('/\<div class="price offerprice bold"\>(.*?)<\/div>/', $input, $matches);
if ($success > 0) {
  print_r($matches[1]);
}
?>
</pre>

Open in new window

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

vishnu kalakotaAuthor Commented:
Hi Julian
I have   sample html here i tried ur code just giving empty array?


<div id="product-list">
<ul>
<li class="product">
<a class="no_underline" href="/shop/m20ProductDisplayView?catalogId=10551&langId=-1&productId=298516&storeId=10151">
<div class="image-wrapper">
<span class="details">
<span class="name">iPhone 6 16GB Gold</span>
<span class="price">
<div class="price offerprice bold"> $986.00 </div>
</span>
</span>
</a>
<div id="productdetail_298516" data-id="298516" data-inventory="search">
</li>
<li class="product">
<a class="no_underline" href="/shop/m20ProductDisplayView?catalogId=10551&langId=-1&productId=298518&storeId=10151">
<div id="productdetail_298518" data-id="298518" data-inventory="search">
<div class="availability availability-wide">
</div>
</li>
<li class="product">
<a class="no_underline" href="/shop/m20ProductDisplayView?catalogId=10551&langId=-1&productId=298522&storeId=10151">
<div id="productdetail_298522" data-id="298522" data-inventory="search">
<div class="availability availability-wide">
<div class="row-fluid inline-availability" data-placement="bottom" data-html="true" data-scroll="" data-content="<div class='search-page-popover'> <div class='availability'> <h2>Delivery</h2> <div class='row-fluid deliver-to-door instock'> <div class='icon'></div> <div class='desc'> <div class='title store-title'>Deliver to Door</div> <div class='message'>Dispatched <span class="highlight-green">NEXT</span> business day</div> </div> </div> </div> <div class='divider'></div> <div class='availability'> <h2>My Store: <span class='regular'>Cannington </span></h2> <div class='row-fluid click-and-collect instock'> <div class='icon'></div> <div class='desc'> <div class='title store-title'>Click & Collect</div> <div class='message'> Collect in 2 business days </div> </div> </div> <div class='row-fluid in-store outofstock'> <div class='icon'></div> <div class='desc'> <div class='title store-title'>Shop in Store</div> <div class='message'>Out of stock in store</div> </div> </div> </div> </div> " data-toggle="popover" data-original-title="" title="">
</div>
</div>
</li>
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<li class="product">
<a class="no_underline" href="/shop/m20ProductDisplayView?catalogId=10551&langId=-1&productId=299532&storeId=10151">
<div class="image-wrapper">
<span class="details">
<span class="name">iPhone 6 Plus 64GB Gold</span>
<span class="price">
<div class="price offerprice bold"> $1,285.00 </div>
</span>

Open in new window

</span>
</a>
0
Julian HansenCommented:
Thanks Vishnu - in future it is a good idea to provide this at the start of your question. Ray also asked for data and you supplied this
<span class="price">
<div class="price offerprice bold"> $986.00 </div>
</span>

Open in new window

I have tried your code in my sample and I get this
Array
(
    [0] =>  $986.00 
    [1] =>  $1,285.00 
)

Open in new window

As far as I can tell it is correctly picking up both occurrences of price in the sample text.
See sample here to verify http://www.marcorpsa.com/ee/t829.php
t829.php
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vishnu kalakotaAuthor Commented:
'@<div  class="price offerprice bold">(.*?)</div>@si',
0
vishnu kalakotaAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for vishnu kalakota's comment #a40836765

for the following reason:

Its working fine for me
0
Julian HansenCommented:
Its working fine for me
Is it working based on responses here - or because of a solution you found yourself, if the latter can you provide details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.