References in Foreach in PHP

When working with the foreach loop, changing the variable for elements does not lead to changes in the array itself:

php<?php
  $arr = [1, 2, 3, 4, 5];
  
  foreach ($arr as $elem) {
    $elem++;
  }
  
  var_dump($arr); // will not change
?>

However, the desired effect can be achieved if you declare the variable for elements as a reference. In this case, changes to this variable will lead to changes in the array:

php<?php
  $arr = [1, 2, 3, 4, 5];
  
  foreach ($arr as &$elem) {
    $elem++;
  }
  
  var_dump($arr); // will change
?>
Задание 1

Fix the following code so that it works as intended:

php<?php
  $arr = [1, 2, 3, 4, 5];

  foreach ($arr as &$elem) {
    $elem = sqrt($elem);
  }
  
  var_dump($arr); 
?>
Задание 2

Fix the following code so that it works as intended:

php<?php
  $arr = [1, 2, 3, 4, 5];

  foreach ($arr as &$elem) {
    $elem ** 2;
  }
  
  var_dump($arr); 
?>