TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-05-2009, 08:53 AM   #1 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default Same as ET..

I need this translated, please. Any takers?

PHP Code:
#!/usr/bin/env python
import random

def rand
(n):
    
10000000
    r 
= [random.randint(0x) for i in xrange(n)]

    
isrt(r)
    for 
i in r:
        print 
i

def isrt
(a):
    for 
j in range(1len(a)):
        
key a[j]
        
1
        
while (>= 0) and (a[i] > key):
            
a[i+1] = a[i]
            
1
        a
[i+1] = key

rand
(2000
cachepl0x is offline  
Reply With Quote
Old 12-05-2009, 01:27 PM   #2 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

No translation services unfortunately but I will tell you that all this does is create a random string. Simply google random string generator in php will do.
__________________
My Blog
Enfernikus is offline  
Reply With Quote
Old 12-05-2009, 01:51 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,381
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by cachepl0x View Post
I need this translated, please. Any takers?

PHP Code:
// Example:
my_rand(2000);

function 
my_rand($n) {
    
$max  10000000;
    
$nums = array();
    
    
// Generate set of random numbers between 0 and $max (inclusive)
    
for($i 0$i $n$i++) {
        
$nums[] = mt_rand(0$max);
    }
    
    
// Sort in ascending numerical order
    
sort($numsSORT_NUMERIC);
    
    
// Output the numbers
    
foreach ($nums as $num) {
        echo 
$num "\n";
    }

Salathe is offline  
Reply With Quote
Old 12-06-2009, 02:32 AM   #4 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default

Thanks, Salathe. I wrote the original, I just wanted to see how it would be implemented in PHP. I hadn't really used PHP's sort() function, and I am surprised at how simple it is for a sorting algorithm.
cachepl0x is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:47 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design