我有一个问题,我想用php替换一个带有str_replace的文本。我在tinymce编辑器中有一个textarea文本,我在那里加载图像。图像保存在数据库../image.png现在我想要用storage.com替换../但不要替换,我不明白问题在哪里
$text = $this->input->post('text', TRUE);
$text = addslashes($text);
$text = str_replace('../','http://storage.com/',$text);
请帮帮我。
答案 0 :(得分:0)
您的替换代码似乎工作正常。您的代码的第一行可能会返回除您期望的其他内容
$text = '../image.png';
echo $text . "\n";
$text = addslashes($text);
$text = str_replace('../','http://storage.com/',$text);
echo $text . "\n";
此代码输出
../image.png
http://storage.com/image.png