将所有爆炸数组放入一个字符串
假设我有一个名为 str
的字符串,我不知道它有多长。 字符串中的字符在每 16 个字符后用“-”分隔。 现在我调用了类似 $ex =explode('-', $str);
的函数。 现在它在数组中。我改变了数组中的一些字符。例如 $ex[0][0] = 'a';
现在我想将更改后的数组连接回变量 $str2
。 类似 $str2 = $ex[0].ex[1]
但我不知道该数组有多长。
你知道怎么做吗?
如果您不明白我的解释,请告诉我。
真的非常感谢。
let's say I have a string called str
, I dont know how long is that.
characters in the string are separated by '-' after each 16th character.
Now i called function like $ex = explode('-', $str);
.
Now it is in array. I have changed some chracters in array. for example $ex[0][0] = 'a';
Now I want to connect that changed arrays back to variable $str2
.
Something like $str2 = $ex[0].ex[1]
but I don't know how long is that array.
Do you know how?
IF you didnt understand my explaination, tell me.
Thank you really much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你想要内爆:
http://php.net/manual/en/function.implode .php
示例:
I think you want implode:
http://php.net/manual/en/function.implode.php
Example:
尝试:
这将获取
$ex
的所有元素,并将它们连接成一个字符串,并在每个元素之间使用第一个参数。在本例中:-
。如果您不希望它们通过任何东西连接,那么您可以这样做:
Try:
This will take all of the elements of
$ex
and connect them into one string with the first parameter between each element. In this case:-
.If you don't want them to be connected by anything, then you can just do:
使用 foreach。 Foreach 允许您遍历数组并在到达末尾时自动停止。
一个例子是:
Use foreach. Foreach allows you to run through the array and automatically stop when the end has been reached.
An example would be: