i've written this function to visualise arrays I'm working on
function printOutput($data) { //ini_set("memory_limit","512M"); foreach ( $data as $key => $value) { print '<div style="border:1px solid #008; padding:4px; margin:8px;">'; // if (is_array($value)){ echo $key.': => (array)'; $this->printOutput($value); }else{ echo $key.': '.$value; } echo '</div>'; } }
but it's realy nasty with memory when you pass it a big array like for example joomlas $GLOBALS array (which I tried to test it on and my VirtualServer ran out of memory).
what can I do to make it more memory efficient? I thought passing data by refference could help like this:
function printOutput($data) { //ini_set("memory_limit","512M"); foreach ( $data as $key => $value) { print '<div style="border:1px solid #008; padding:4px; margin:8px;">'; // if (is_array($value)){ echo $key.': => (array)'; $this->printOutput($value); }else{ echo $key.': '.$value; } echo '</div>'; } }
but that didn't help either. i tried upping the max memory php can allocate up to 712MB (available system memory atm) but nothing...
As far as i understand the way I have written the function each new invocation needs a bit less memory than its previous one, actively multiplying the size of the variable passed by the arrays depth. is there a different way to handle arrays that just uses the one array?
So, if someone has experience in stuff like this please let me know ok? thanks