I'm trying to get $randpros
to be something like this 0.15 but i got a problem $randpros = 0.$randpri;
wont work.
Here is the code I've tried:
$randpri = rand(5,15);
$randpros = 0.$randpri;
is there another way to add 0. infront of $randpros
?
use double quotes as follows:
$randpri = rand(5,15);
$randpros = "0.{$randpri}";
Cast it as a Float:
$randpros = floatval("0." . $randpri);
Do plain math!
Case "I want to pass a random integer as float point to zero":
$randpros = 0.01*(rand(5,15));
Case "I want a random integer to pose as float point to zero":
$i = rand(5,15);
$randpros = $i < 10 ? (0.1*$i) : (0.01*$i);
If you are in need of a random number format 0.xx
<?php
echo ( rand( 0, 99 ) / 100 );
?>