I have binary basically, say it's 300 in length. How would I split (much like using explode) it into 8 bit chunks? I look at chunk_split() but it only seems to have an 'end' parameter, not an option to put it into an array.. Or can it be socketed into an array?
The end 8 digits can be below 8 (in case a miscopy from someone, and it's 4) so no validation is needed, just consistantly in 8 number chunks from the start to end.
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. This functions returns an array containing the strings formed by splitting the original string.
The chunk_split() function splits a string into a series of smaller parts.
PHP - Function split() The split() function will divide a string into various elements, the boundaries of each element based on the occurrence of pattern in string.
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
:
$chunks = str_split($data, 8);
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