php string to char array

207

php string to char array -

<?php

$str = "Hey Arkadaş";

$arr1 = str_split($str);
$arr2 = str_split($str, 3);

print_r($arr1);
print_r($arr2);

?>

/*
Rasult:
  Array
(
    [0] => H
    [1] => e
    [2] => y
    [3] =>
    [4] => A
    [5] => r
    [6] => k
    [7] => a
    [8] => d
    [9] => a
    [10] => �
    [11] => �
)
Array
(
    [0] => Hey
    [1] =>  Ar
    [2] => kad
    [3] => aş
)*/

php convert string to chars -

<?php

$str = "Hello Friend";

$arr1 = str_split($str);
$arr2 = str_split($str, 3);

print_r($arr1);
print_r($arr2);

?>

Comments

Submit
0 Comments