Skip to content
Advertisement

PHP str_replace with array() not working ? (have example)

[code]

echo str_replace(array('(', ')'), '', "(test) i'm test"); exit;

[run]

(test) i'm test

I want to remove brackets from this text, but it not working?

Advertisement

Answer

This code removes parentheses (, ) from the following string:

(test) i'm test"

$string = "(test) i'm test";
echo str_replace(array( '(', ')' ), '', $string);

The results after using the str_replace() function:

test i'm test"

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