Fairly easy to see the problem if you format your code properly with the correct indentation:
<?php
function detect()
{
$arr_browsers = ["Opera", "Edg", "Chrome", "Safari", "Firefox", "MSIE", "Trident"];
$agent = $_SERVER['HTTP_USER_AGENT'];
foreach ($arr_browsers as $browser) {
if (\strpos($agent, $browser) === true){
echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';
}
else if (\strpos($agent, $browser) === true){
echo 'Dátum zákroku / Date of procedure [YYYY-MM-DD]';
echo '<p><input class="w3-input w3-border" required name="datum_zakroku"></p>';
}
else{
'<div class="w3-text-d1"><p>Dátum zákroku / Date of procedure</p></div>
<p><input class="w3-input w3-border" type="date" required name="datum_zakroku"></p>';
}
}
detect()
?>