PHP/String/Replace

Материал из Web эксперт
Перейти к: навигация, поиск

preg_replace: replace date

   <source lang="html4strict">

<? $t = "25/12/99, 14/5/00"; $t = preg_replace( "|\b(\d+)/(\d+)/(\d+)\b|", "\\2/\\1/\\3", $t ); print "$t
"; ?>

      </source>
   
  


the m modifier to change the behavior of $

   <source lang="html4strict">

<? $text = "Name: matt\noccupation: coder\neyes: blue\n"; preg_match_all( "/^\w+:\s+(.*)$/m", $text, $array ); foreach ( $array[1] as $val ) {

   print "$val
";

} ?>

      </source>