PHP str_split() Function

Home > PHP Tutorial > PHP str_split() Function

Best PHP Live Project Based Winter Training in Noida for more details click here



PHP str_split() Function

Splits a string into an array with the help of str_split() function. Syntax

str_split(string,length)

Example 1

<?php
$str="hello";
$array=str_split($str);
print_r($array);
?>
Output Array ( [0] => h [1] => e [2] => l [3] => l [4] => o )

Example 2(Passing Length Parameter)

<?php
$str="hello";
$array=str_split($str,2);
print_r($array);
?>
Output Array ( [0] => he [1] => ll [2] => o )