Home  »  CodeLibrariesProgrammingSnippetsTechnology   »   Check if String Length is Greater Than Zero in PHP

Check if String Length is Greater Than Zero in PHP

Posted: May 11, 2022 | by Michael Bright

Use this code snippet to check if string length is greater than zero in PHP.

if( strlen( trim( $string )) > 0 ){

   // do something cool if $string has at least one non-space character

}

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.