Search code snippets, questions, articles...

Calculate length of a string using strlen() function in php

   echo strlen("foo bar"); 
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output will be : 7

To get the length of a string strlen() function is used in PHP. In the code, we have passed a string which has the value - 'foo bar'. It will return '7' as an output as the string length. 

Was this helpful?