Benvenuto Posted August 14, 2003 Report Share Posted August 14, 2003 <code><font color="#000000"> ereg_replace (" is", " was", $string); </font> </code> shinii rindinjaa is repleisos ar was, bet man ir jautaajums kaa vareetu uzreiz defineet visus burtus vai vaardus kurus veelos repleisot un visus tos burtus vai vaardus kurus gribu likt to vietaa taa, lai nebuutu katru reizi jaaraksta ereg_replace... rindinja? Link to comment Share on other sites More sharing options...
Little_Hacker Posted August 14, 2003 Report Share Posted August 14, 2003 /me nezini bet taa uz aatru domu iedomaajos ka mozh ar masiiviem (array) ?! Kaut ko vareetu sabiidiit.. man skjiet ka php manuaali ir kaut kaads liidziigs paraugs.. :blink: Link to comment Share on other sites More sharing options...
bassz Posted August 15, 2003 Report Share Posted August 15, 2003 <?php function censor($text) { $mask = "-"; $badwords = array("badword1", "badword2", "badword3"); for ($i = 0; $i < sizeof($words); $i++) { $censored = substr($badwords[$i], 0, 1); for ($x = 1; $x < strlen($badwords[$i]); $x++) $censored .= $mask; $text = str_replace($badwords[$i], $censored, $text); } return $text; } ?> Link to comment Share on other sites More sharing options...
Kaklz Posted August 16, 2003 Report Share Posted August 16, 2003 <code><font color="#000000"> ereg_replace (" is", " was", $string);</font> </code> shinii rindinjaa is repleisos ar was, bet man ir jautaajums kaa vareetu uzreiz defineet visus burtus vai vaardus kurus veelos repleisot un visus tos burtus vai vaardus kurus gribu likt to vietaa taa, lai nebuutu katru reizi jaaraksta ereg_replace... rindinja? mosh nevis ereg_replace, bet preg_replace? ;) Quote from: http://lv.php.net/manual/en/function.preg-replace.php If pattern and replacement are arrays, then preg_replace() takes a value from each array and uses them to do search and replace on subject. Link to comment Share on other sites More sharing options...
Venom Posted August 17, 2003 Report Share Posted August 17, 2003 Bet, ja neizmanto ereg_ un preg_ nevietā, tad noder šāda fiška: $translate=array( ' is '=>'was', ' does '=>' did ' ); $text=strtr($text,$translate) echo $text; Atkal, ja piem. jānomaina case-insensitive (jebšu is, IS, Is vai iS vienalga jānomaina par was), izmanto to pašu fišku, bet tad vienā arrajā liek patternus (šājā gadījumā varētu izskatīties kā (ja forums atkal nenoēdīs slashus) '/\b(vārds)\b/imU') bet citā - "tulkojumus". See preg_replace() man. Link to comment Share on other sites More sharing options...
Benvenuto Posted August 17, 2003 Author Report Share Posted August 17, 2003 jaa preg replace vareetu nodereet. :) Link to comment Share on other sites More sharing options...
Recommended Posts