Autor | Zpráva | ||
---|---|---|---|
final Profil |
Zdravím,
$text="mám takýto [c]text[/c]["; function change($text){ return StrTr($text,"[c][/c]", "<b></b>"); } echo change($text); return StrTr($text,"[u][/u]", "<div class='underline'></div>"); StrTr nahrádza každý znak osobitne..
Existuje nejaká funkcia, ktorá by nahradzovalo presne [u] za <div class='underline'> alebo ako to riešiť ?
ďakujem |
||
Chuchycek Profil |
#2 · Zasláno: 31. 10. 2012, 10:43:43
Zkus to pomocí str_replace() nebo si najdi bbcode.
|
||
peta Profil |
preg_replace - pouzij
str_replace - se da pouzit, ale musel bys kazdy kod zapsat zvlast a ne takhle spolecne.
http://cz2.php.net/function.strtr Take se da pouzit, Example #2 strtr() example with two arguments <?php $trans = array("h" => "-", "hello" => "hi", "hi" => "hello"); echo strtr("hi all, I said hello", $trans); ?> See Also str_replace() - Replace all occurrences of the search string with the replacement string preg_replace() - Perform a regular expression search and replace |
||
final Profil |
ďakujem, použitie strtr() je myslím jednoduchšia možnosť
|
||
Časová prodleva: 11 let
|
0