Formatering af tal i PHP
number_formatЗадание 1
Givet en streng:
php<?php
$str = '12345678';
?>
Lav den om til en streng:
php'12 345 678'
Задание 2
Givet et tal:
php<?php
$number = 9876543.21;
?>
Formatér tallet, så det har tusindseparatorer (mellemrum) og to cifre i decimaldelen:
php'9 876 543.21'
Задание 3
Givet et tal:
php<?php
$price = 1234.5678;
?>
Formatér tallet med tusindseparatorer (punktum), to cifre i decimaldelen og en valutasymbol:
php'€1.234,57'