Arvis Arvis - 1 year ago 99
PHP Question

Replace ">" and every character after the special character

i am a beginner in PHP and would want to replace ">" and every other character after it in a string.>testmail

Answer Source

This should do the trick

 $string = '>testmail';
 $pattern = '/(>(.*?))$/i';
 $replacement = 'helloWorld';
 echo preg_replace($pattern, $replacement, $string);

More about preg_replace;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download