Tuesday, August 18, 2015

How to Convert a String into Array in PHP?

  • str_split — Convert a string to an array

                 Example:-

                 $pid = str_split($arrpid);
                 $pack_id = count($pid);
  • chunk_split() - Split a string into smaller chunks
  • preg_split() - Split string by a regular expression
  • explode() - Split a string by string
  • count_chars() - Return information about characters used in a string
  • str_word_count() - Return information about words used in a string

How to Convert a String into Array & count the size using PHP functions?