Jump to content

replace a string and put the replaced string on a variable


regicidedelferoz

Recommended Posts

good day everyone,. i want to replace a string and put the replaced string on a variable,. ex. $str = 'this is the oRiGiNaL text';$find = 'original';$replace = 'replaced'; output:$str = 'this is the replaced text'; //the normal output of replacing text $original = 'oRiGiNaL'; //the replaced text will be moved to a new variable and it's format/case is remain thanks in advance,. -regicide del feroz

Link to comment
Share on other sites

If you need the case preserved then you can use preg_match to find the match from the case-insensitive search string, then use str_replace to replace the matched text with the replacement text. http://www.php.net/manual/en/function.preg-match.phphttp://www.php.net/manual/en/function.str-replace.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...