How to remove text with accents in php?

1

I have the following situation, the text below it has the following words ATENÇÃO: and será which in turn they are accented, they must be removed from the text but due to the accents I can not remove.

$string = "ATENÇÃO: O produto será revisado e constatado o defeito será";

$remover = array ("ATENÇÃO:","será");

echo $texto = str_replace("$remover","",$string);

Expected result.

  

Product reviewed and found defect

    
asked by anonymous 18.02.2017 / 01:11

2 answers

3

Your logic works perfectly with accents, the problem is that you are transforming the array with elements to remove in a string .

See the following, I just changed the array statement to short syntax and removed the extra quotation marks:

<?php

$string = "ATENÇÃO: O produto será revisado e constatado o defeito será";

$remover = ["ATENÇÃO:","será"];

echo $texto = str_replace($remover, "", $string);

See working here .

PS: Warning with error messages, run your original function was returning the following error:

  

Notice: Array to string conversion in / in / fLpSU on line 7

    
18.02.2017 / 01:23
2

Take the double quotation marks from the $remover variable.

echo $texto = str_replace($remover,"",$string);'

See how it works in IDEONE

    
18.02.2017 / 01:21