PHP:字符串分割到8块,我该怎么办呢? [英] PHP: Split string into chunks of 8, how do I do this?

查看:138
本文介绍了PHP:字符串分割到8块,我该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有二进制基本上说,它的长度为300。我将如何拆分(就像使用爆炸),它变成8位块?我看 chunk_split(),但它只是似乎有一个'端'参数,而不是把它变成一个数组的一个选项..还是可以嵌到一个数组中?

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?

末8位数可以低于8(如果从别人miscopy,它是4),所以不需要验证,只是consistantly在8号区块从开始到结束。

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.

推荐答案

str_split

$chunks = str_split($data, 8);

这篇关于PHP:字符串分割到8块,我该怎么办呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆