Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 361
Trades: 0
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 !
__________________

Please login or register to view this content. Registration is FREE


NuWeb 10101101
NuWeb.co.uk is offline
Reply With Quote
View Public Profile Visit NuWeb.co.uk's homepage!
 
 
Register now for full access!
Old 05-13-2006, 05:18 PM Re: JS random code --- What its equivilant in php?
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
"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, 11:40 AM Re: JS random code --- What its equivilant in php?
Extreme Talker

Posts: 161
Location: Netherlands
Trades: 2
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
Please login or register to view this content. Registration is FREE
.
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.21106 seconds with 12 queries