我想替換'<'和'>'登錄字符串。 如如何替換php中的字符串
$str = 'if x<y and y>z'; echo str_replace('<', 'something', $str) . "\n";
此給出的結果
if xsomethingy and y>z
我的問題是我怎麼能代替 '>' 文本 '東西'
我想替換'<'和'>'登錄字符串。 如如何替換php中的字符串
$str = 'if x<y and y>z'; echo str_replace('<', 'something', $str) . "\n";
此給出的結果
if xsomethingy and y>z
我的問題是我怎麼能代替 '>' 文本 '東西'
preg_replace(/[<>]/g, 'something', $str)
你需要學習一些PHP呀
http://php.net/manual/en/function.preg-replace.php
退房preg_replace()
文檔這裏http://php.net/manual/en/function.preg-replace.php
例子是 preg_replace('/[<>]/', 'something', $str);
......用同樣的方法? – 2010-11-26 06:42:03