Reputation: 73
So I have this piece of code
$text2 = "abcd";
$text2 = str_replace(
array('a', 'b', 'c', 'd'),
array('dbac ', 'cabd ', 'bacd ', 'adbc '),
$text2
);
and text2 is "adbc bacadbc abadbc abacadbc bacadbc abadbc bacadbc adbc" but I wanted to have dbac cabd bacd adbc. How to avoid that recursion replacing?
Upvotes: 0
Views: 112
Reputation: 964
It looks like you could simply use the PHP strrev function:
$text2 = "aabbccdd";
$text2 = strrev($text2); // ddccbbaa
Upvotes: 0