Sunday 27 July 2014

Filled Under:

str_split() in php

str_split() :

                               str_split() function that is use to divide the string into array

syntax:

str_split(string, number of character);
number of character: its optional argument it takes numeric value greater than zero its by default value is one. Its value mean how many character will be stored in the indexes of arrays.

Example:

<?php
$str=”php”;
Print_r(str_split($str));
print_r(str_split($str,2));
?>

Output:

          Array ( [0] => p [1] => h [2] => p )
          Array ( [0] => ph [1] => p )
               




0 comments:

Post a Comment