Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to find the number of words and number of characters in a string?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 99
    Comment on it

    Find the number of words in a string:

    In PHP, to find number of words in a string a function str_word_count() is used. It includes three parameters:

    • string: It a required parameter which specify the string to check.
    • return:It is an optional parameter that specify the return value.
    • char: It is also an optional parameter that specify special character to be considered as words.

    Syntax:

    str_word_count(string,return,char)
    

    Returns a number or array that depends upon the chosen return parameter. The default value is 0 i.e., the number of words found.

    Find the length of a string:

    To find length of a string a function strlen() is used. It includes one parameter which is the string whose length you want to find.

    Syntax:

    strlen(string)
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: