php - preg_replace not replacing with ajax -
i have following code
$text = '["{!account__!http://localhost/mf/public/__notactivated}","email"]'; $replcmnt = array( '#{!account__!http:\/\/localhost\/mf/public\/__notactivated}#' => 'text replace' ); $text = preg_replace(array_keys($replcmnt),$replcmnt,$text);
i need output '["text replace","email"]'
reason replace isn't replacing. find extremely weird works when load page doesn't work if run via ajax request o.o
i have note if remove slashes inner part between underscores replace takes place. problem must slashes.
ex.
$replcmnt = array( '#{!account__!http:-localhost-mf-public-__notactivated}#' => 'text replace' );
the above replaced due lack of slashes, suppose.
any appreciated
edit:
here's data right before replace:
$text ["{!account__!http:\/\/localhost\/mf\/public\/__notactivated}","email"] $replcmnt array ( [#{!account__!http:\/\/localhost\/mf\/public\/__notactivated}#] => long text )
use str_replace()
rather preg_replace()
, since you're not doing pattern matching.
Comments
Post a Comment