user1765876
user1765876

Reputation:

Does str_replace() modify by reference?

I am trying to change a string with str_replace()`.

str_replace("****",$res->id,$my_file);

But it is not changing the string. I don't know how to debug the scenario.

Upvotes: 0

Views: 300

Answers (1)

ThiefMaster
ThiefMaster

Reputation: 318468

You need to assign the returned string to your variable. None of PHP's *_replace functions modify the original string in-place.

$my_file = str_replace("****", $res->id, $my_file);

Upvotes: 4

Related Questions