Display the drop-down list

preg_match_all()

« preg_match | preg_quote »
<?php
$int 
preg_match_all (
    
// string $pattern
    
// string $subject
    
// [array &$matches]
    
?// [int $flags = PREG_PATTERN_ORDER]
    
  // [int $offset = 0]
);
?>
Result
$out = [
  
=> [
    
=> '<b>example: </b>',
    
=> '<div align="left">this is a test</div>',
  ],
  
=> [
    
=> 'example: ',
    
=> 'this is a test',
  ],
]
$int = 2
Examples
#1 preg_match_all  ("|<[^>]+>(.*)</[^>]+>|U",
 
"<b>example: </b><div align=\"left\">this is a test</div>",
 
$out,
 
PREG_PATTERN_ORDER)
#2 preg_match_all  ("|<[^>]+>(.*)</[^>]+>|U",
 
"<b>example: </b><div align=\"left\">this is a test</div>",
 
$out,
 
PREG_SET_ORDER)
#3 preg_match_all  ('/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x',
 
"Call 555-1212 or 1-800-555-1212",
 
$phones)
#4 preg_match_all  ('/(<([\w]+)[^>]*>)(.*?)(<\/\2>)/',
 
"<b>bold text</b><a href=howdy.html>click me</a>",
 
$matches,
 
PREG_SET_ORDER)
#5 preg_match_all  ('/(?P<name>\w+): (?P<digit>\d+)/',
 
"a: 1 b: 2 c: 3",
 
$matches)
See also
preg_last_error, preg_match, preg_quote, preg_replace, preg_split