str_replace ....

Forumas skirtas klausimams/pamokoms susijusioms su PHP, SQL (MySQL), web technologijomis, HTML, CSS, javascript, turinio valdymo sistemomis ir kita.
Post Reply
Spag
Gana aktyvus vartotojas
Posts: 269
Joined: 2012 Dec 31 15:39

str_replace ....

Post by Spag »

Kaip tekste esamus simbolius, tokius kaip: %ip%, %labas% pakeisti į $ip, $labas

Taigi kaip tokiame tekste tuos simbolius pakeisti į mano nurodytus?

Su str_replace reikia, bet kaip pridėti daugiau replace į tą tekstą... ?

Code: Select all

$challenge = '-aaa----b-c-----d--e---f'; echo str_replace('--', '-', $challenge).
čia pavyzdys, bet kaip dėti tikrinimą IR ?

User avatar
psychical
Viršininkas
Posts: 2094
Joined: 2011 Mar 12 22:19
Skype: tautvydas11
Location: Linksmakalnis
Contact:

Re: str_replace ....

Post by psychical »

Jei netingėtum paieškot, o ne prašinėt susirastum pats http://bg2.php.net/str_replace

Example #1 Basic str_replace() examples

Code: Select all

<?php// Provides: <body text='black'>$bodytag = str_replace("%body%", "black", "<body text='%body%'>"); // Provides: Hll Wrld f PHP$vowels = array("a", "e", "i", "o", "u", "A", "E", "I", "O", "U");$onlyconsonants = str_replace($vowels, "", "Hello World of PHP"); // Provides: You should eat pizza, beer, and ice cream every day$phrase  = "You should eat fruits, vegetables, and fiber every day.";$healthy = array("fruits", "vegetables", "fiber");$yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase); // Provides: 2$str = str_replace("ll", "", "good golly miss molly!", $count);echo $count;?>

Spag
Gana aktyvus vartotojas
Posts: 269
Joined: 2012 Dec 31 15:39

Re: str_replace ....

Post by Spag »

dekui

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests