How to detect English/ASCII string in PHP

There is no direct function for this in my knowledge. But it can be done easily like so.

“`php
if ( mb_strlen( $string, ‘ASCII’ ) === mb_strlen( $string, ‘utf-8’ ) ) {
return true;
}
“`

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *