How to overwrite pointer assoziation in php? Or how to operate on arrays with n dimensions? -


I have a dirty little problem with php (& amp;) indicator operator; I want to loop through a while loop I, who writes data in an array Each time it is assumed to be written in the next dimension of the array (in the first $ array, then $ array [0], then array [0] [0], etc.) I wanted to do this by adding the array to array with the array, then changing the pointer in such a way:

  $ pointer = & amp; Array; While ($ bla) {$ pointer = & amp; $ Pointer [0]; }  

Then the Indicator link is turned on for another dimension of $ array each time. It does not seem to work though ...

I really thank you for your help, thank you.

I tried your code and it works. Test:

  & lt ;? Php error_reporting (E_ALL | E_STRICT); $ Array = array (); $ Ptr = & amp; $ Array; For ($ i = 0; $ i <10; ++ $ i) {$ ptr [0] = array (); $ Ptr = & amp; $ Ptr [0]; } Unset ($ ptr); Var_dump ($ array); $ Ptr = & amp; $ Array; While (! Empty ($ ptr)) {$ ptr = & amp; $ Ptr [0]; Var_dump ($ ptr); }  

This creates the first array and then loops it again.


Comments