Friday, October 17, 2008

The str_split() function

This function splits a string into an array of strings.

syntax: str_split(string[,length]);

string – the input string
length – the number of characters each element in the output array must hold. The default value is 1.

Example input:

$str1="This is a simple program number";
print_r(str_split($str1,5));

Example output:

Array ( [0] => This [1] => is a [2] => simpl [3] => e pro [4] => gram [5] => numbe [6] => r )

No comments: