preg_replace 置換
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> $string = <<<str …………………… <img src="/img/pvistely/1.jpg" /> <img src="/img/pvistely/2.jpg" /> <img src="/img/pvistely/3.jpg" /> …………………… str; $pattern = array('<img src="/img/pvistely/1.jpg" />','<img src="/img/pvistely/2.jpg" />','<img src="/img/pvistely/3.jpg" />'); $replace = array('[img]1.jpg[/img]','[img]2.jpg[/img]','[img]3.jpg[/img]'); echo preg_replace($pattern, $replace, $string);
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> …………………… <[img]1.jpg[/img]> <[img]2.jpg[/img]> <[img]3.jpg[/img]> ……………………