Php rand()

Exemples de code

8
0

générateur de nombres aléatoires en php

you can use rand() function for that in php.
Example:
Generate random numbers between 1 to 50
<?php
  echo rand(1,50);
?>
7
0

php nombre aléatoire

// $min and $max are optional
rand($min,$max);
6
0

php chaîne aléatoire

function rand_str() {
    $characters = '0123456789-=+{}[]:;@#~.?/&gt;,&lt;|\!"£$%^&amp;*()abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomstr = '';
    for ($i = 0; $i < random_int(50, 100); $i++) {
      $randomstr .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomstr;
  }
4
0

générateur de nombres aléatoires php

<?php
  echo rand(1,50);
?>
2
0

php rand int

random_int ( int $min , int $max );
2
0

php entier aléatoire

echo random_int(0,50);
1
0

php nombre aléatoire

rand(0,10);
or
random_int(0,10)
0
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);
0
0

randstring php

<?php 
    $random = substr(md5(mt_rand()), 0, 7);
    echo $random;
?>

Dans d'autres langues

Cette page est dans d'autres langues

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................