3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bom = "\xef\xbb\xbf"; $json_string = $bom.'{"greeting":"Hello world"}'; var_dump( $json_string, json_decode($json_string, true), preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string), json_decode( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $json_string), true ) );
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
string(29) "{"greeting":"Hello world"}" NULL string(26) "{"greeting":"Hello world"}" array(1) { ["greeting"]=> string(11) "Hello world" }

preferences:
45.88 ms | 406 KiB | 5 Q