PHP changes the value of the loop PHP
Foreach ($ array as $ key =>&$ value) {// if $ value is also an array // I want to split $ value for example, enough to split 2 this $ result = array_slice ($ value ); // $ value = array_slice ($ value, 3) in the next loop; // Q: How is the array of array_slice ($ value, 3) in the next loop );}
I just got in touch with PHP. can you help me?
Reply to discussion (solution)
foreach($array as $key=>&$value){foreach($value as $key2=>&$value2){foreach($value2 as $key3=>&$value3){}}}
If I have other operations in the loop upstairs, it will be very troublesome.
I want
$ Value after Segmentation
Then assign a value to $ value.
Then prev ($ array );
I don't know if this is feasible. I'm testing it.
Recursion...
Write a recursive method.
No!
Because after the array is passed into foreach, it cannot control its internal pointer externally.
You can use the for loop with array_splice
It may be possible to use ArrayObject to implement it through the iterator. it is hard to say that it has never been done.
What if we append data to the array $ array of the loop?
In this way, the split array will be recycled.
Is there any of the above problems?
Yes, but it depends on the final value.
Foreach is not allowed
First, use a foreach to put the content you split into another array, and then the new foreach array won't be enough?
Or you can try while (each ())