using php how do i generate random numbers?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pitchke
    New Member
    • Sep 2007
    • 7

    using php how do i generate random numbers?

    how do i generate random no's...also i want to convert that no. to the corresponding string...using PHP!!!!!
    thanks in advance..
    Tarun
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    Use rand() then cast the number to a string (string)

    Comment

    • pitchke
      New Member
      • Sep 2007
      • 7

      #3
      [CODE=PHP]
      <?php

      $a = rand(1,1000);

      print "<p> ($a)</p>\n";

      print "Click the Reload button on your browser to get a new random number.";

      ?>
      [/CODE]
      hey this what i have done...
      Now can you alter things in the same code and show me how to do it...i also want to print the resulting string in a image form...
      Thank you in advance..
      Tarun.

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        Now can you alter things in the same code and show me how to do it
        Well thank you. But I would like to see more of what you have done then I can work out what you are trying to do.
        Ta.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Tarun.

          Please use CODE tags when posting source code:

          &#91;CODE=ph p]
          PHP code goes here.
          &#91;/CODE]

          Removed unnecessary '?'s from your thread title that may have made people less likely to want to look at your thread.

          Comment

          Working...