Mantis - Quercus
Viewing Issue Advanced Details
4058 minor always 06-01-10 03:11 06-01-10 03:11
sblommers  
 
normal  
new 4.0.8  
SVN open  
none    
none  
0004058: print_r not going through whole array when references are used
OUTPUT on APACHE+PHP:
BEFORE SANITIZE: Array ( [0] => Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 ) [1] => 3 [2] => 4 ) [1] => 5 [2] => 6 )
AFTER SANITIZE: Array ( [0] => Array ( [0] => Array ( [0] => \0 [1] => \1 [2] => \2 ) [1] => \3 [2] => \4 ) [1] => \5 [2] => \6 )

OUTPUT on QUERCUS:
BEFORE SANITIZE: Array ( [0] => Array ( [0] => Array ( [0] => 0 [1] => 1 [2] => 2 ) [1] => 3 [2] => 4 ) [1] => 5 [2] => 6 )
AFTER SANITIZE: Array ( [0] => Array [1] => \5 [2] => \6 )
<?php

// Sanitize as a function to allow recursing; original array passed by reference
function sanitize(&$array) {
        foreach ($array as &$data) {
                if (!is_array($data)) // If it's not an array, clean it
                        $data = '\\' . $data; // addslashes(), mysql_real_escape_string() or whatever you wish to use, this is merely a simple example
                   else // If it IS an array, call the function on it
                        sanitize($data);
        }
}

// Test case
$test = array(
        array(
                        array(
                                0,
                                1,
                                2
                        ),
                        3,
                        4
                ),
                5,
                6
        );
// Output
echo "BEFORE SANITIZE: ";
print_r($test);
sanitize($test);
echo "
AFTER SANITIZE: ";
print_r($test);
?>

There are no notes attached to this issue.