-4

I have a feed that pulls from social feeds. These feeds can sometimes include special characters such as emojis that don't translate well:

enter image description here

I just want to strip out any characters that can't be displayed. I know that might remove a few that I could want but that's fine. I know I can do a regex but not really sure how to target like what's in the photo.

---EDIT---

This is what is throwing the characters above:

enter image description here

dcp3450
  • 10,959
  • 23
  • 58
  • 110

1 Answers1

2

Try using PHP Sanitize Filters, most specifically FILTER_SANITIZE_SPECIAL_CHARS

<?php
$a = 'text including "unprintable" characters';
$sanitized_a = filter_var($a, FILTER_SANITIZE_SPECIAL_CHARS);
echo $sanitized_a;
?>

Just be careful using this if there are some characters you want (like < and > for instance)! Check the link at the top for a full list of filters you can choose from.

SteJ
  • 1,491
  • 11
  • 13