Answers for "math.rand in php"

PHP
0

randstring php

<?php 
    $random = substr(md5(mt_rand()), 0, 7);
    echo $random;
?>
Posted by: Guest on April-21-2020
0

randhex php

function random_part() {
    return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}

function randomHEX($amount) {
  $_result = "";
  for ($i = 0 ; $i < $amount; $i++) {
    $_result .= random_part();
  }
  return $_result;
}

//to get a 16 HEX number
echo randomHEX(8);
Posted by: Guest on November-10-2020

Browse Popular Code Answers by Language