php – str_split

<?php
$str
= "Hello World";
$arr1 = str_split($str);
$arr2 = str_split($str, 3);
print_r($arr1);
print_r($arr2);


// This function helps in converting a string into array.

// 1. Array
( [0] => H
[1] => e
[2] => l
[3] => l
[4] => o
[5] =>
[6] => W
[7] => o
[8] => r
[9] => l
[10] => d
The string is splited into array.
2.Array
[0] => Hel
[1] => lo
[2] => Wor
[3] => ld
Each array the string is splited into 3.
?>

2 Comments »

  1. balaji said

    can understood

  2. kutty said

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: