All pastes #784944 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-19 22:52 UTC
rendered paste body
<?php

$con = array(
		'error' => array(
			'fatal' => 5, 
			'db' => array(
				"mysql" => array(
					"reported" => 73, "not_reported" => 541),
				"pgsql" => array(
					"reported" => 1, "not_reported" => 148)
				)
			)
		);

function pimpmyarray($a,$depth,$parents){
    foreach($a as $k=>$v){
        if (is_array($v)){
            $a[$k]=pimpmyarray($v,$depth+1,$parents.".".$k);
        } else {
            if ($k=='reported' && $parents == 'con.error.db.mysql'){ # This could be more elegant...
                $a[$k]=5;
            }
        }
    }
    return $a;
}

echo "Output: ";
print_r(pimpmyarray($con,0,"con"));
?>