Skip to content
Advertisement

Replace string in PHP – not working with longer string

I am beginner in php.

I have this code:

JavaScript

It’s working fine when I use this function:

JavaScript

But problem is when I have:

JavaScript

I need result:

JavaScript

How repair this function?

Advertisement

Answer

An easy way for your example to work is to create an array of all the words in your input, and check each of them separately. Here is an example:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement