Jump to content

[SOLVED] preg_match_all only grabbing first match


diondev

Recommended Posts

I can't figure this out....I'm trying to match all the elements of menu span's:

 

<?php

$menu = '
<div id="menu">
<span class="menuitem"><a href="#">Menu Item 1</a></span>
<span class="menuitem"><a href="#">Menu Item 2</a></span>
<span class="menuitem"><a href="#">Menu Item 3</a></span>
</div>
';

preg_match_all('|<span class="menuitem">(.*)</span>|i', $menu, $menu_matches);
print_r($menu_matches);

?>

 

For whatever, reason, it is only printing Menu Item 1 in the array

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.