Hướng dẫn php rand decimal
I need to generate a random number, to the 10th spot between 2 decimals in PHP. Show Ex. A rand number between 1.2 and 5.7. It would return 3.4 How can I do this? asked May 2, 2012 at 18:24
1 You can use:
or even better:
answered May 2, 2012 at 18:27
codaddictcodaddict 434k80 gold badges487 silver badges524 bronze badges 1 You could do something like:
PHP's random function allows you to only use integer limits, but you can then divide the resulting random number by 10. answered May 2, 2012 at 18:25
DeletemanDeleteman 8,2806 gold badges24 silver badges39 bronze badges A more general solution would be:
answered May 2, 2012 at 18:36
driangledriangle 11.4k4 gold badges45 silver badges51 bronze badges 1 Not the answer you're looking for? Browse other questions tagged php random or ask your own question.(PHP 4, PHP 5, PHP 7, PHP 8) hexdec — Hexadecimal to decimal Descriptionhexdec(string hexdec() will ignore any non-hexadecimal characters it encounters. As of PHP 7.4.0 supplying any invalid characters is deprecated. Parametershex_string The hexadecimal string to convert Return Values The decimal representation of Changelog
ExamplesExample #1 hexdec() example
Notes
See Also
hafees at msn dot com ¶ 12 years ago
programacion at mundosica dot com ¶ 10 years ago
flurinj at gmx dot net ¶ 12 years ago
brian at sagesport dot com ¶ 17 years ago
strip_chars($string, $char){ chuckySTAR ¶ 13 years ago
$dec; k10206 at naver dot com ¶ 14 years ago
Halit YEL - halityesil at globya dot net ¶ 12 years ago
$l){
Anonymous ¶ 17 years ago
Walter Wlodarski ¶ 14 years ago
sneskid at hotmail dot com ¶ 10 years ago
jose dot rob dot jr at gmail dot com ¶ 13 years ago
var_dump(hexbin('0xF8F800'));
Ultimater at gmail dot com ¶ 13 years ago
floatinghexdec("ff.ff");//255.99609375 helpmedalph at gmail dot com ¶ 6 years ago
chrism at four dot net ¶ 20 years ago
joquius at kakugo dot com ¶ 13 years ago
Anonymous ¶ 14 years ago
Manithu ¶ 15 years ago
cgarvis at gmail dot com ¶ 15 years ago
repley at freemail dot it ¶ 16 years ago
$pointer = 0; $pointer < $tot-1 ; $pointer++) {$hexstart = $hex_array[$pointer]; cory at lavacube dot com ¶ 16 years ago
$out; detrate at hotmail dot com ¶ 16 years ago
= "336699"; // color Gabriel Reguly ¶ 17 years ago
bishop ¶ 17 years ago
$asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb);
zubfatal, root at it dot dk ¶ 17 years ago
$x = 0; $x < count($arrColors); $x++) { groobo ¶ 17 years ago
this1is4me at hotmail dot com ¶ 14 years ago
maddddidley at yahoo dot com ¶ 14 years ago
andreas.schmeiler ¶ 19 years ago
ayadav at infoprocorp dot com ¶ 16 years ago
andy at haveland dot com ¶ 11 years ago
strtohex("Knowledge is power")."\n";
Rosberg - rosberglinhares at gmail dot com ¶ 12 years ago
|