Strings in PHP:

String is a sequence of characters. In PHP there are some common functions which we can use on strings.

  • strlen()
  • strrev()
  • str_word_count()
  • str_pos()
  • str_replace()
  • strtoupper()
  • strtolower()

 strlen() in PHP:

To get the length of the string the “strlen()” function is used in PHP means “strlen()” function returns the no of characters of the string and it also calculate the space.

Example:

 strrev() function in PHP:

To print a string in a reverse order the “strrev()” function is used. You can understand it easily by example.

Example:

 str_word_count() function in PHP:

The “str_word_count()” function in PHP is use to count the no of words in a statement or string.

Example:

 strpos() function in PHP:

The “strops()” function in PHP is used to find the position of the specific word within the string and returns the result in number. The resulted number is noting but the position of first character of the word.

Example:

 str_replace() Function in PHP:

You can replace a string In PHP by using “str_replace()” function. You have defined the string which you want to replace and also define the new string which you want in replace with old string.

Example:

 strtoupper() Function in PHP:

The strtoupper()” function in PHP is use to convert the string in upper alphabetical case.

Example:

 strtolower() Function in PHP:

The strtolower()” function in PHP is use to convert the string in lower alphabetical case.

Example:

 

5 responses to “String Functions in PHP”

  1. Javier Grissinger says:

    Only wanna input on few general things, The website style is perfect, the subject material is very wonderful : D.

  2. Derek Sekulski says:

    Respect to article author, some great entropy.

  3. Shay Antonelli says:

    I like it when people get together and share thoughts. Great blog, keep it up!

  4. Aisha Thom says:

    Aw, this was a very nice post. Finding the time and actual effort to make a good article… but what can I say… I hesitate a lot and never manage to get nearly anything done.

  5. Bradley Carmella says:

    I am impressed with this site, real I am a fan.

Leave a Reply

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