How to split files from array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to split files from array

    PHP Code:
    <?php
    $cats
    =array(
    "turn the beat on-beat production.mp3"=>"turn the beat on-beat production",
    "the final destiny-virus.mp3"=>"the final destiny-virus",
    "the access of trance-dj crack.mp3"=>"the access of trance-dj crack",
    "star wars theme-plan @ work.mp3"=>"star wars theme-plan @ work",
    "secret desire-steven gore.mp3"=>"secret desire-steven gore",
    "paradise-t.o..mp3"=>"paradise-t.o.",
    "out of sight-copycat.mp3"=>"out of sight-copycat",
    "my definition of trance-lord razor.mp3"=>"my definition of trance-lord razor",
    "magic melody-groove solution.mp3"=>"magic melody-groove solution",
    "god danced-dj taylor & flow.mp3"=>"god danced-dj taylor & flow",
    );
    shuffle($cats);
    foreach(
    $cats as $key=>$cat){
    $lnk="<b>» </b><a href=\"file.php?file=Club/$key&start=1\">$cat</a><br/>";
    echo 
    $lnk;
    }
    ?>
    DISPLAY:
    Club
    » my definition of trance-lord razor
    » magic melody-groove solution
    » god danced-dj taylor & flow
    » star wars theme-plan @ work
    » secret desire-steven gore
    » the access of trance-dj crack
    » the final destiny-virus
    » turn the beat on-beat production
    » paradise-t.o.
    » out of sight-copycat

    HELP ME... I NEED TO DISPLAY 5 LINKS ONLY...

    #2
    PHP Code:
    $n=0;
    shuffle($cats); 
    foreach(
    $cats as $key=>$cat){ 
    $lnk="<b>» </b><a href=\"file.php?file=Club/$key&start=1\">$cat</a><br/>"
    echo 
    $lnk
    $n++;
    if(
    $n==5)
    break;

    Comment


      #3
      thank you!!!

      Comment


        #4
        sir is there a script that can autoindex this type of array? in short to have a pagination... there will be no problem on sorting from new to old i just not to insert that shuffle(); thing... my only problem is how to split the total output into 5 and having a pagination...

        Comment


          #5
          PHP Code:
          <?php 
          $amount 
          5;
          $page = (int)$_GET['page'];
          if(!isset(
          $page)||$page<1$page 1;
          $limit $page $amount;
          $cats=array( 
          "turn the beat on-beat production.mp3"=>"turn the beat on-beat production"
          "the final destiny-virus.mp3"=>"the final destiny-virus"
          "the access of trance-dj crack.mp3"=>"the access of trance-dj crack"
          "star wars theme-plan @ work.mp3"=>"star wars theme-plan @ work"
          "secret desire-steven gore.mp3"=>"secret desire-steven gore"
          "paradise-t.o..mp3"=>"paradise-t.o."
          "out of sight-copycat.mp3"=>"out of sight-copycat"
          "my definition of trance-lord razor.mp3"=>"my definition of trance-lord razor"
          "magic melody-groove solution.mp3"=>"magic melody-groove solution"
          "god danced-dj taylor & flow.mp3"=>"god danced-dj taylor & flow"); 
          $total count($cats);
          if(
          $limit>$total$limit $total;
          foreach(
          array_slice($cats$limit-$amount$amount) as $key=>$cat){ 
          echo 
          "<b>» </b><a href=\"file.php?file=Club/$key&start=1\">$cat</a><br/>"

          $pagelimit ceil($total/$amount);
          echo 
          '<a href="'.$_SERVER['PHP_SELF'].'">1 </a>';
          if(
          $page>2)
          echo 
          '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page-1).'">'.($page-1).' </a>';
          if(((
          $total/$amount)>$page)&&($page!=($pagelimit-1)))
          echo 
          '<a href="'.$_SERVER['PHP_SELF'].'?page='.($page+1).'">'.($page+1).' </a>';
          if(
          $pagelimit>1)
          echo 
          '<a href="'.$_SERVER['PHP_SELF'].'?page='.$pagelimit.'">'.$pagelimit.' </a>';
          ?>

          Comment


            #6
            thank you again sir.... much appreciated i will use this code... i will study also.. thanks a lot...

            Comment


              #7
              is there any script that compress mp3...? e.g. compress into 128KBPS 64KBPS 32KBPS....

              Comment


                #8
                Sir the link is not correct is display like this file.php?file=Club/0 til 4 i think there's something wrong on shuffle.. how will i fix this....

                Comment


                  #9
                  you dont have to use the key if the cat is the same (just missing .mp3) eg:
                  PHP Code:
                  echo '<b>» </b><a href="file.php?file=Club/'.$cat.'.mp3&start=1">'.$cat.'</a><br/>'

                  Comment


                    #10
                    yeah $cat has no .mp3 thats why im using this function cause i don't want the .mp3 to be appeared.. anyway tnx for the response since im using autoindex here im going to use $cat with .mp3 on url.

                    Comment


                      #11
                      i'm having a difficult to fix the wrong output using this code.. ex. i have total files of 31 when you view the last page you should see only one link to display but its not you will see 10 links, the 9 links displayed were repeated from the previous page but the last link is the correct link to displayed on page 3...

                      Comment

                      Working...
                      X