note 84703 modified in function.preg-replace by danbrown

From: Date: Fri, 28 Nov 2008 19:45:26 +0000
Subject: note 84703 modified in function.preg-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147135@lists.php.net to get a copy of this message
<?php //:::replace with anything that you can do with searched string::: //Marcin Majchrzak //pixaltic.com $c = "2 4 8"; echo ($c); //display:2 4 8 $cp = "/(\d)\s(\d)\s(\d)/e"; //pattern $cr = "'\\3*\\2+\\1='.(('\\3')*('\\2')+('\\1'))"; //replece $c = preg_replace($cp, $cr, $c); echo ($c); //display:8*4+2=34 ?> --was-- <? //:::replace with anything that you can do with searched string::: //Marcin Majchrzak //pixaltic.com $c = "2 4 8"; echo ($c); //display:2 4 8 $cp = "/(\d)\s(\d)\s(\d)/e"; //pattern $cr = "'\\3*\\2+\\1='.(('\\3')*('\\2')+('\\1'))"; //replece $c = preg_replace($cp, $cr, $c); echo ($c); //display:8*4+2=34 ?> http://php.net/manual/en/function.preg-replace.php

« previous php.notes (#147135) next »