str_replace generating error Array to string conversion

1

I am trying to change some characters shown in array by empty space but the code causes me the following error:

  

Array to string conversion

str_replace($string, array(',', '.'), '')

I do not see an error, what can it be?

    
asked by anonymous 13.05.2016 / 22:12

1 answer

3

The problem is that the arguments are in the wrong order, $string must be last because it is the string to be replaced.

The first argument $serach is which character (s) should be found, $replace is and why (ais) should be replaced and $subject is the string or variable in which to replace, $count is the number of its institutions.

  

mixed str_replace (mixed $ search, mixed $ replace, mixed $ subject [ int & count])

$string = '100,39';
echo str_replace(array(',', '.'), '', $string);
    
13.05.2016 / 22:21