Replace preg_replace. how can I always [eat] a character before... why should I use the following code to replace it. how can I always eat the previous character ...... the code is as follows... PHPcode $ newstextpreg_replace (. $ r [keyname]. u, & lt; ahref. $ r [keyurl]. t replace preg_replace. how can I always [eat] a character before...
Why should I use the following code to replace it? how can I always eat the previous character ......
The code is as follows...
PHP code
$newstext = preg_replace('/'.$r[keyname].'/u',''.$r[keyname].'',$newstext,$public_r[repkeynum]);
PHP code
$newstext = preg_replace('/[^=>]'.$r[keyname].'/u',''.$r[keyname].'',$newstext,$public_r[repkeynum]);
For example,... string = "my good day has started"
Key words: beauty
After the replacement, it became: My good day has started.
I am so depressed ....
------ Solution --------------------
No. What is your $ r [keyname?
------ Solution --------------------
Method 1 is correct
The second is what you said: [^ =>] will eat a character
------ Solution --------------------
Solution
------ Solution --------------------
$ Str = "My Wonderful Day has started ";
$ Newstext = preg_replace ('/beautiful/', 'Beautiful ', $ str );
Echo $ newstext;
?>