$string ="<mytag>hhsfasfgia fdhftgh</mytag>"; // the solution below was taken from a forum // with or without this line doesn't make any difference // some kind of windows and linux's difference in multiline // $string = str_replace("\r\n","\n",$string); $string = preg_match_all("/(<([\w]+)[^>]*>)(.*)(<\/\\2>)/m",$string,$match); print '<pre>'; print_r($match); print '</pre>'; PHP: As u can see multiline mode is already ON but still it can't match the string. If i change the string to : $string ="<mytag>hhsfasfgiafdhftgh</mytag>"; PHP: It can match ! Any idea? Thank you.
Thanks, Jay! It works. But i have a question, isn't m represents multi-line mode? and s represents single-line mode? How come it works in single line mode? Thank you anyway, +rep
You're welcome m means that ^ and $ will match at line breaks (multiline) but s means that the . will match all characters including the newline http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php Jay