Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Random mp3

  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Random mp3

    Hi everyone can someone help me php random mp3 code i want everytime loads home page plays new mp3.

    Thanks all

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    would your mp3 names be numbers or letters?

    change chars to what letters/numbers would be allowed...

    PHP Code:
        function CreateRandomCode($len) {
            
    $chars "123456789";
            
    srand((double)microtime()*1000000);
            
    $code '' ;
            
    $len++;

            for (
    $i=0;$i<=$len$i++) {
                
    $num rand() % 33;
                
    $tmp substr($chars$num1);
                
    $code $code $tmp;
            }
            return 
    $code;
        } 
    and on ur page it would be something like:

    PHP Code:
    echo CreateRandomCode(2) . ".mp3"
    assuming that you have 99 mp3 and there names are gonna be :
    1.mp3
    2.mp3
    3.mp3
    .....

  • #3
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Or just change the code on this page:

    http://www.codingforums.com/showthread.php?t=94922


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •