How to compare and replace values in two dimensional arrays

$a = array(000,400,000,500);
    $b = array(300,400,450,500);

    $i=0;
    foreach($b as $k=>$v)
    {
        if($v==$a[$i])
        {
            $b[$k]='000';
        }
        $i++;
    }

    print_r($b);

i want same thing in two dimensional array

$a = Array ( [0] => Array ( [0] => 000000 [1] => 000400 [2] => 000450 ) [1] => Array ( [0] => 000350 [1] => 000400 ) )

$b = array(0=>000350,1=>000400,2=>000450) //pre-defined installment amount values