Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/exercises/strings/

strings.php
strings1.php
strings1fb.php
strings2.php
strings2fb.php
strings3.php
strings3fb.php
strings4.php
strings4fb.php
strings5.php
strings5fb.php
strings6.php

strings3fb.php

24 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Stränghantering</title>
</head>
<body>
  <?php
    
if (isset($_POST["t"]) && isset($_POST["n"])) {
      
$num $_POST["t"] / $_POST["n"];

      
$decPoint mb_strpos($num".");

      if (
$decPoint === false) {
        echo 
$num;
      } else {
        echo 
mb_substr($num0$decPoint 3);
      }
      
    }
  
?>
</body>
</html>