Skip to content

Instantly share code, notes, and snippets.

@denihida1216
Last active October 29, 2021 02:50
Show Gist options
  • Save denihida1216/a884877e4169d493b52030ceca78cab2 to your computer and use it in GitHub Desktop.
Save denihida1216/a884877e4169d493b52030ceca78cab2 to your computer and use it in GitHub Desktop.
PHP json encode - Malformed UTF-8 characters
<?php
$song = 'Can&#039;t Get Enough';
#solved1
var_dump(mb_convert_encoding($song, 'UTF-8', 'HTML-ENTITIES'));
#solved2
var_dump(json_encode($song, JSON_INVALID_UTF8_IGNORE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment