Copyright © tutorialspoint.com

PHP Function preg_match_all()

previous
Advertisements

Syntax

int preg_match_all (string pattern, string string, array pattern_array [, int order]);

Definition and Usage

The preg_match_all() function matches all occurrences of pattern in string.

It will place these matches in the array pattern_array in the order you specify using the optional input parameter order. There are two possible types of order:

Return Value

Example

Following is the piece of code, copy and paste this code into a file and verify the result.

<?php

$userinfo = "Name: <b>John Poul</b> <br> Title: <b>PHP Guru</b>";
preg_match_all ("/<b>(.*)<\/b>/U", $userinfo, $pat_array);
print $pat_array[0][0]." <br> ".$pat_array[0][1]."\n";

?>

This will produce following result.

John Poul
PHP Guru

previous

Copyright © tutorialspoint.com