Php
foreach ($array as $key =>& $value) { //If $value is also an array //I want to split $value For example enough to split 2 of this $result = Array_ Slice ($value, 0,3); $value of the next loop = array_slice ($value, 3); Q: How is the next loop array for array_slice ($value, 3); }
I just got in touch with PHP guys, help me.
Reply to discussion (solution)
foreach ($array as $key =>& $value) {foreach ($value as $key 2=>& $value 2) {foreach ($value 2 as $key 3=>& $value 3) {}}}
Upstairs, if I have other operations in the loop, it's going to be a hassle.
I want to
After $value split
and re-assign the $value.
Then prev ($array);
I don't know if that's possible. Testing
With recursion ...
Write a recursive method, and you're done.
No!
Since the array is passed in to foreach, it is not possible to manipulate its internal pointers externally.
You can use the For loop with Array_splice to implement
Maybe you can do it with arrayobject through an iterator, not done, not good.
If the array $array the loop, append the data.
This will eventually loop to the segmented array.
Have the above problem?
For Yes, but depends on the final value of the notation
foreach Can not
First use a foreach to put your segmented content into another array, and then the new array of foreach is not OK?
Or you can try the next (each ())