Replace a text using php

user3611170

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.

Zois

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related