Link to home
Start Free TrialLog in
Avatar of lawrence_dev
lawrence_dev

asked on

Where am I going wrong with this preg-match?

I am trying to pull all of the data between two <div> tags and I am getting the following error:

Notice: Undefined offset: 1.

What am I doing wrong?

preg_match('%<div class="productdescription" itemprop="description">(.*?)<\/div>%i',$buffer,$matches16);
  
        $LongDesc=$matches16[1];		 

echo $LongDesc."<BR>";	

Open in new window



Here is the description I am attempting to get:

START HERE ---->   <div class="productdescription" itemprop="description">
                <p>
    Built with assistance from bike patrol officers nationwide, the 5.11 Bike Patrol Polo was designed to provide bike mounted officers with a safe, reliable,
    and thoroughly professional alternative to baggy or constricting police bike patrol shirts. Crafted from lightweight, breathable, high performance jersey
    knit polyester, the 5.11 Bike Patrol Polo offers superior moisture wicking performance, quick drying action, and anti-microbial characteristics that keep
    you looking and feeling your best all day long. Integrated reflective tape increases visibility, an underarm gusset ensures full freedom of movement, a
    generous length and drop tail ensures your bike polo stays tucked in, and a mic loop at the placket keeps you connected. Best of all, the bright colors on
    our bike patrol shirts are colorfast against perspiration and sunlight, ensuring a clean, professional appearance throughout your shift.
</p>
<ul>
    <li>
        Chest Pen Pocket
    </li>
    <li>
        Underarm gusset for mobility
    </li>
    <li>
        Integrated reflective tap
    </li>
    <li>
        Moisture wicking, quick drying, anti-microbial
    </li>
    <li>
        Mic loop at front placket
    </li>
    <li>
        Colorfast to Light &amp; Perspiration
    </li>
    <li>
        Jersey knit polyester
    </li>
    <li>
        Performance Fit
    </li>
    <li>
        Generous Length
    </li>
    <li>
        Drop tail
    </li>
</ul>
            </div>     <---   END HERE

Open in new window

SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lawrence_dev
lawrence_dev

ASKER

Kaufmed & Terry,  Thanks!  Easy to understand.  

Ray, Way too technical and difficult to understand.  The more simple it is, the easier it is to understand, and build on.  If I could understand the examples on php.net, I would not need Experts-Exchange!