0
我試圖替換[picasa和],但以下代碼片段無法正常工作。PHP - 爲什麼preg_replace不工作?
$vars = '[picasa flashvars="host=picasaweb.google.com&hl=en_US&feat=flashalbum&RGB=0x000000&feed=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F100016363917755589270%2Falbumid%2F5578059546640576577%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_US" width="288" height="192"]';
$patterns[0] = "/\[picasa\] /";
$patterns[1] = "/\]/";
$replacements[0] = "<embed type='application/x-shockwave-flash' src='https://picasaweb.google.com/s/c/bin/slideshow.swf'";
$replacements[1] = " pluginspage='http://www.macromedia.com/go/getflashplayer'>";
$match = preg_replace($patterns,$replacements,$vars);
echo $match;
我知道我可以使用str_replace,但我想用preg_replace代替。
我在這裏做錯了嗎?
//啊!你是對的。 – Moon 2011-03-02 05:30:38