PHP - hexdec
Třída
Metoda - hexdec
(PHP 4, PHP 5, PHP 7)
Funkce hecdec v PHP vrací převod z šestnáctkové (hexadecimální) do desítkové (decimální) soustavy. Tato funkce jde naprosto jednoduše nahradit funkcí base_convert, která je univerzální.
Procedurální
- function hexdec (string $hex_string) : number
Parametry
Název | Datový typ | Výchozí hodnota | Popis |
---|---|---|---|
$hex_string | string | Hexadecimální číslo (vyjádřeno jako textový řetězec) k převodu. |
Návratové hodnoty
Vrací: number
Převedené číslo jako numerický typ (number).
Příklady
<?php
$array = array("f8", "-b", "itnetwork", "e", "148", 11);
foreach ($array as $value)
echo ("'$value' (hex) => dec: '" . hexdec($value) . "'<br>");
Tato ukázka vypíše (pokud zobrazeno ve webovém prohlížeči):
'f8' (hex) => dec: '248' '-b' (hex) => dec: '11' 'itnetwork' (hex) => dec: '14' 'e' (hex) => dec: '14' '148' (hex) => dec: '328' '11' (hex) => dec: '17'
Související manuály
- function base_convert (string $number, int $frombase, int $tobase) : string
- function bindec (string $binary_string) : number
- function dechex (int $number) : string
- function octdec (string $octal_string) : number