Change values of the specific key in a multidimensional array

I need to change values of key [productId] in array arr with values from array arr2. The result should be the next:

Array ( [0] => Array ( [productId] =>9404 [stockQuantity] => 10 [incoming] => [prices] => ) [1] => Array ( [productId] =>9401 [stockQuantity] => 15 [incoming] => [prices] => ))

Here is my code:

$data = '[
  {
    "productId": "NPQ10",
    "stockQuantity": 10,
    "incoming": null,
    "prices": null
  },
  {
    "productId": "WS11",
    "stockQuantity": 15,
    "incoming": null,
    "prices": null
    }
]';
  
$arr = json_decode($data, true);
$arr2 = array();
for ($i = 0; $i < count($arr); $i++) { 
    $id = wc_get_product_id_by_sku($arr[$i][productId]);
    array_push($arr2,$id);
}
for($j = 0; $j <= count($arr2); $j++) {
    foreach ($arr as &$entry) {
        foreach ($entry as $key => &$val) {
            if ($key == "productId") {
                $val=$arr2[$j];
            }
        }
   }
}
print_r($arr); 

How to achieve that?