Mega Code Archive

 
Categories / Php / Strings
 

S modifier

//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"; } ?>