SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP String Functions

str_split

We can split a string with fixed intervals ( without using any delimiter ) by using PHP str_split command. The output we will get an array with broken string of fixed length. This breaking of string is different than explode as no delimiter is used to split the string. Here is the syntax.
str_split(string, integer of length )
Let us try one example
$string="Welcome to Plus2net Php section";
print_r(str_split($string,5));
The output is here
Array ( [0] => Welco [1] => me to [2] => Plus [3] => 2net [4] => Php s [5] => ectio [6] => n ) 
Let us see if we don't use any length integer. The output array will have elements of single char. Means it will be broken across each char or the default value will be 1.
$string="Welcome to Plus2net Php section";
print_r(str_split($string));
Output is here
Array ( [0] => W [1] => e [2] => l [3] => c [4] => o [5] => m [6] => e [7] => [8] => t
 [9] => o [10] => [11] => P [12] => l [13] => u [14] => s [15] => 2 [16] => n [17] => e 
[18] => t [19] => [20] => P [21] => h [22] => p [23] => [24] => s [25] => e [26] => c 
[27] => t [28] => i [29] => o [30] => n ) 

Be the first to post comment on this article :


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer