PREG_PATTERN_ORDER specifies the order in the way that you might
think most logical: $pattern_array[0] is an array of all complete pattern
matches, $pattern_array[1] is an array of all strings matching the first parenthesized
regular expression, and so on.
??? PREG_SET_ORDER orders the array a bit differently than the default setting.
$pattern_array[0] contains elements matched by the first parenthesized
regular expression, $pattern_array[1] contains elements matched by the
second parenthesized regular expression, and so on.
Here??™s how you would use preg_match_all() to find all strings enclosed in bold
HTML tags:
$userinfo = "Name:
Zeev Suraski Title:
PHP Guru";
preg_match_all("/
(.*)<\/b>/U", $userinfo, $pat_array);
printf("%s
%s", $pat_array[0][0], $pat_array[0][1]);
?>
This returns the following:
Zeev Suraski
PHP Guru
Delimiting Special Regular Expression Characters
The function preg_quote() inserts a backslash delimiter before every character of
special significance to regular expression syntax. These special characters include $ ^
* ( ) + = { } [ ] | \\ : < >. Its prototype follows:
string preg_quote(string str [, string delimiter])
The optional parameter delimiter specifies what delimiter is used for the regular
expression, causing it to also be escaped by a backslash. Consider an example:
CHAPTER 9 ?– S TRINGS AND REGULAR EXPRESS IONS 245
$text = "Tickets for the bout are going for $500.
Pages:
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323