Return to Snippet

Revision: 53027
at November 10, 2011 09:46 by anagaiyahoocom


Initial Code
$data = '<html>

<body>
<jdoc:include type="head" name="popup" style="raw" />

<jdoc:include type="modules" name="dochead" style="raw" />

</body>

</html>';

if(preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\/>#iU', $data, $matches))
{
  Will return
  $matches = 
  [0][0] = "<jdoc:include type="head" name="popup" style="raw" />"
  [0][1] = "<jdoc:include type="modules" name="dochead" style="raw" />"
  
  [1][0] = head
  [1][1] = modules

  [2][0] = name="popup" style="raw"
  [2][1] = name="dochead" style="raw"
}

Initial URL

                                

Initial Description
This will search for specific type of tag in html doc and extract type attribute value and all attributes after it in tag.

Initial Title
Regular expression search multiple matches in PHP

Initial Tags
php

Initial Language
PHP