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.

if ( mb_strlen( $string, 'ASCII' ) === mb_strlen( $string, 'utf-8' ) ) {
    return true;

By Abhineet Mittal

Abhineet is IIM Alumnus and Founder of popular Digital Publishing Platform, Sahityapedia. He is a technology enthusiast by hobby & an avid reader.