m modifier: match an anchored pattern on multiple lines of text.
The anchor patterns ^ and $ match the beginning and end of an entire string by default.
<?
$text = "name: Joe\noccupation: coder\n\n";
if ( preg_match_all( "/^\w+:\s+(.*)$/m", $text, $array ) ) {
print "<pre>\n";
print_r( $array );
print "</pre>\n";
}
?>
Related examples in the same category