0

I have a problem,I want to replace a text with str_replace using php.I have a textarea in tinymce editor with text and I loaded image there.The image is saved in database ../image.png now I want to replace ../ with storage.com but don't replace and I don't understand where is the problem

$text         = $this->input->post('text', TRUE);
$text         = addslashes($text);
$text         = str_replace('../','http://storage.com/',$text);

Help me please.

user3611170
  • 33
  • 1
  • 8

1 Answers1

0

Your replacement code seems to work fine. The first line of your code probably returns something else than what you expect

$text         = '../image.png';
echo $text . "\n";
$text         = addslashes($text);
$text         = str_replace('../','http://storage.com/',$text);
echo $text . "\n";

This code outputs

../image.png
http://storage.com/image.png
Zois
  • 61
  • 6