4

I'm importing data from excel to data table. It's working fine. But in some fields, data imported with unknown character '�'. But excel doesn't have such character. Here is my code.

I have tried in many ways. This is my final code.

$new_prod_desc = (ucfirst($data[0])." ".ucfirst($data[5])." ".ucfirst($data[1])." ".ucfirst($data[2])); $new_prod_desc = preg_replace("/&#?[a-z0-9]+;/i","",$new_prod_desc);

Thanks.

Devpower
  • 43
  • 2
  • 6

2 Answers2

2

That is not a single byte character, but a UTF-8 sequence ef bf bd:

From here:

U+FFFD  �   ef bf bd    REPLACEMENT CHARACTER

Maybe it is replacing an even worse character?

If you just want it to vanish, you could search and replace the byte sequence.

wallyk
  • 56,922
  • 16
  • 83
  • 148
0

First verify that the excel document is in UTF-8 code.

Try to add the function

utf8_decode

like this:

$new_prod_desc = utf8_decode($new_prod_desc);
Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171