3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = "🚁- Tour @exslagermaurice"; function is_ascii( $str ) { return ( bool ) !preg_match( '/[\x80-\xFF]/' , $str ); } /** * utf8_single_chr_html_encode( ) * * Converts a UTF-8 character to HTML Numbered Entity like &#123; * @since 1.0 * * @param string $chr The Unicode character to be encoded as numbered entity * @return string HTML numbered entity */ function utf8_single_chr_html_encode( $chr ) { return '&#' . utf8_ord( $chr ) . ';'; } /** * utf8_html_encode( ) * * Converts a UTF-8 string to a series of * HTML Numbered Entities like &#123;&#39;&#1740;... * @since 1.0 * * @param string $str The Unicode string to be encoded as numbered entities * @return string HTML numbered entities */ function utf8_html_encode( $str ) { return implode( array_map( 'utf8_single_chr_html_encode' , utf8_split( $str ) ) ); } var_dump(utf8_html_encode($foo));

preferences:
33.79 ms | 402 KiB | 5 Q