note 67785 added to function.str-replace

From: Date: Wed, 05 Jul 2006 17:12:08 +0000
Subject: note 67785 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-114358@lists.php.net to get a copy of this message
Inspired by the first official example here, that gives "<body text='black'>", I wrote a little function that replaces strings using a "dictionary": function sablongep($sablon, $helyettesites) { foreach ($helyettesites as $nev => $adat) $sablon=str_replace("%$nev%", $adat, $sablon); return $sablon; } Example: sablongep("We have a lot of fruits: %fruits%, and some vegetables: %vegetables%.", array( "fruits" => "apple, banana, cherry", "vegetables" => "carrot, cabbage")); I admit that this example is not as funny as the others in the manual... ---- Server IP: 195.70.37.52 Probable Submitter: 217.116.34.73 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/note/edit/67785 Del: integrated -- http://master.php.net/note/delete/67785/integrated Del: useless -- http://master.php.net/note/delete/67785/useless Del: bad code -- http://master.php.net/note/delete/67785/bad+code Del: spam -- http://master.php.net/note/delete/67785/spam Del: non-english -- http://master.php.net/note/delete/67785/non-english Del: in docs -- http://master.php.net/note/delete/67785/in+docs Del: other reasons-- http://master.php.net/note/delete/67785 Reject -- http://master.php.net/note/reject/67785 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114358) next »