diondev Posted July 29, 2009 Share Posted July 29, 2009 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 Quote Link to comment Share on other sites More sharing options...
Adam Posted July 29, 2009 Share Posted July 29, 2009 Try: preg_match_all('|<span class="menuitem">(.*?)</span>|i', $menu, $menu_matches); Edit: Actually, it works no problem for me as it is? Quote Link to comment Share on other sites More sharing options...
diondev Posted July 29, 2009 Author Share Posted July 29, 2009 Nevermind, apparently my brain isn't working. I was using preg_match_all on the wrong variable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.