I'd like to get a string, for example 'sdasdasdsdkjsdkdjbskdbvksdbfksjdbfkdbfksdjbf' and split that up every six charaters.
I don't think explode or strtok will work for that?
Any ideas?
PHP | explode() Function explode() is a built in function in PHP used to split a string in different strings. The explode() function splits a string based on a string delimiter, i.e. it splits the string wherever the delimiter character occurs.
The chunk_split() function splits a string into a series of smaller parts. Note: This function does not alter the original string.
The task is to split the given string with comma delimiter and store the result in an array. Use explode() or preg_split() function to split the string in php with given delimiter. PHP | explode() Function: The explode() function is an inbuilt function in PHP which is used to split a string in different strings.
PHP | join() Function The join() function is built-in function in PHP and is used to join an array of elements which are separated by a string.
str_split
was designed for just that.
$str = "sdasdasdsdkjsdkdjbskdbvksdbfksjdbfkdbfksdjbf";
$parts = str_split($str, 6);
print_r($parts);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With