Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP function similar to this JavaScript function

I need a similar function in PHP for this JavaScript function

text = text.replace(/ffc/g, "Hello");

I think preg_replace will do, but i'm not sure how to write the expression..

I want the regular expression similar to /ffc/g which is above, What I need exactly is to match the full word and case when performing the replace...

like image 850
Jude Avatar asked Apr 06 '26 10:04

Jude


1 Answers

$text = preg_replace('/ffc/', 'replacement text',  $subject);

The online manual for PHP is pretty amazing, and one of the languages best features:

http://php.net/preg_replace

like image 195
Erik Avatar answered Apr 09 '26 01:04

Erik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!