s modifier: use . to match characters across multiple lines.
//access the first and last words of a string
<?
$text = "start with this line\nand you will reach\na conclusion in the end\n";
if ( preg_match( "/^(\w+).*?(\w+)$/", $text, $array ) ) {
print "<pre>\n";
print_r( $array );
print "</pre>\n";
}
?>