Zend - The PHP Company




Arrays

Add Code


DumpArray  

Type: application
Added by: RLYNCH
Entered: 27/01/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 7097
Dumps out an array suitable for re-creating using eval()


<?php
    
    
//Note that this dumps an array out in a form suitable to be
    //used with eval() to recreate the array!
    
    
function arrayDump(&$array$col=0){
        if (
is_array($array)){
            echo 
"array(n";
            
$i 0;
            
$count count($array);
            while(
$i $count && list($key$val) = each($array)){
                echo 
$key' ==> ';
                
arrayDump($val$col+1);
                
$i++;
                if (
$i $count){
                    echo 
',';
                }
                echo 
"n";
            }
            echo 
")n";
        }
        else{
            echo 
$array;
        }
    }
    
    for (
$i 0$i 5$i++){
        for (
$j $i$j 4$j++){
            for (
$k $j$k 3$k++){
                
$data[$i][$j][$k] = $i $j $k;
            }
        }
    }
    
    echo 
"<PRE>";
    
arrayDump($data);
    echo 
"</PRE>";
?>


Usage Example




Rate This Script





Search



This Category All Categories