Reply
JS random code --- What its equivilant in php?
Old 05-13-2006, 03:25 PM JS random code --- What its equivilant in php?
NuWeb.co.uk's Avatar
NuWeb.co.uk <-- FUN FUN

Posts: 361
Location: England
Hello, their is a js code, that i have translated for a person into php.
Took me long time concidering im realy bad in js!!

All i need to know is the equivilant of this codeing:
Math.round(Math.random()*10000000)

In php?
Thanks !
__________________
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
When You Register, These Ads Go Away!
     
Old 05-13-2006, 04:18 PM Re: JS random code --- What its equivilant in php?
Ultra Talker

Posts: 252
Location: Auckland, New Zealand
"Math" is just the Javascript native object that contains some basic math functions.

The random() function produces a number between 0 and 1, so it could be any real number with only the limitations of how many decimals it could have.

The round() function is just to truncate the decimals after you have multiplied it so that the number is now a number between 0 and 10000000.

If you know PHP well enough, then you'd easily be able to write something that can imitate the similar effects, if it has to be similar to how it works under javascript.

Or you could just do:

PHP Code:
mt_rand(0,10000000); 
Which I feel is equivalent enough.

Cheers,


MC
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Old 05-16-2006, 10:40 AM Re: JS random code --- What its equivilant in php?
Super Talker

Posts: 137
Location: Netherlands
Remember that "random" is not that random as you would think.
You will get rather often the same values back...

Better is to have a part of the number random, and a part which is raised all the time by one as a Application Variable.
__________________
Visit the Free Online Image Editor.
Add cool effects to your images, and even create your own animated gif's!
Skorpija is offline
Reply With Quote
View Public Profile Visit Skorpija's homepage!
 
Reply     « Reply to JS random code --- What its equivilant in php?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11734 seconds with 13 queries