Friday, April 20, 2007

String Manipulation . explode string

exploding string at each component character

the below mentioned preg_Split() function is very useful in exploding entire string for each of its characters;

$str = 'Mumbai';
$chars = preg_split('//', $str,-1, PREG_SPLIT_NO_EMPTY);
print_r($chars);
output
Array
(

[0] => M
[1] => u
[2] => m
[3] => b
[4] => a
[5] => i
)

No comments: