..


Sponsored Links

str_split

Str_split function converts a string into an array by splitting every X characters. The function accepts two parameters in question:

  • the original string;
  • after how many characters to truncate the string (default = 1).
For example:





 $ Str = "centre-equestre-lepuy.com"







 Str_split $ arr = ($ str);







 print_r ($ arr);



This code produces the following output:





 Array (



  



 [0] => M



  



 [1] => r



  



 [2] =>.



  



 [3] => W



  



 [4] => and



  



 [5] => b



  



 [6] => m



  



 [7] => a



  



 [8] => s



  



 [9] => t



  



 [10] => and



  



 [11] => r







 )



Let's take another example, by specifying this time, the number of characters (in three):





 $ Str = "centre-equestre-lepuy.com"







 Str_split $ arr = ($ str, 3);







 print_r ($ arr);



This script will produce this output:





 Array (



  



 [0] => Mr.



  



 [1] => Web



  



 [2] => mas



  



 [3] => ter







 )



In the same category ...
E-Learning
Linux (Course) Linux (Course)
Complete guide to open-source system. From 49 €.
MySQL (Course) MySQL (Course)
Management of open-source database. From 39 €.
PHP (Course) PHP (Course)
Full course for creating dynamic Web sites. From 49 €.
Sponsored Links