Skip to content
Advertisement

How to remove any special character from php array?

How to remove any special character from php array?

I have array like:

JavaScript

I want result as:

JavaScript

I got result by this way:

JavaScript

But is there any php array function with we can directly remove any character from all values of array? I tried and found only spaces can be removed with trim() but not for any character.

Advertisement

Answer

Use preg_replace function. This will replace anything that isn’t a letter, number or space.

SEE DEMO

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