Showing posts with label funcitons. Show all posts
Showing posts with label funcitons. Show all posts

Thursday, June 28, 2012

php functions on strings

The following are some functions which can be used on strings in php.
  1. str_word_count :- str_word_count has different results depending on parameters.
    • str_word_count($string_variable) returns the word count
    • str_word_count($string_variable, (0,1 or 2)) where
      • 0 returns the word count(the default option)
      • 1 returns an array
      • 2 returns an associative array
    • str_word_count($string_variable, (0,1,2), ' (something to be included as a word for ex '.!&' ').
      • different arguments included next to each other.
  2. str_shuffle($string_variable) :- shuffles string_variable
  3. substr($string_variable,  starting position, ending position) :- returns the substring
  4. strlen($string_variable) :- returns the length of the string_variable
  5. strtolower($string_variable) :- returns $string_variable with all characters in lower case
  6. strttoupper($string_variable) :- returns $string_variable with all characters in upper case