php - split string after x characters -


how split $string after 5 characters array

example:

$string="123456789"; 

expected output

$output[0] contain "12345"; $output[1] contain "6789"; 

if need split string after every 5 characters, try str_split():

$output = str_split($string, 5); 

if need extract first 5 characters , put rest of string in second part of array, can use substr() nulluserexception suggests (code now-deleted answer):

$output[0] = substr($string, 0, 5); $output[1] = substr($string, 5); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -