How to convert a string into array of equal length substrings in PHP

1 Answer

0 votes
$str = "php java c c++ python";

$N = 5;

$arr = str_split($str, $N);

print_r($arr);




/*
run:

Array
(
    [0] => php j
    [1] => ava c
    [2] =>  c++ 
    [3] => pytho
    [4] => n
)

*/

 



answered Aug 23, 2022 by avibootz

Related questions

...