Activity Stream
48,167 MEMBERS
61220 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 3 of 3
  1.     
    #1
    Member
    Website's:
    UmNotaBlogger.com

    Default MediaFire API: want to sort...

    Hello again,
    I am using MediaFire's API to share my stuff... I just post the folder link and the files are automatically parsed... and this is the code snippet that I use (including an example):
    PHP Code: 
    <?php
    $loadxml_folder_info 
    simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
    $max $loadxml_folder_info->folder_info->file_count;
    $output '';
    for (
    $i 0$i $max$i++) {
        
    $mf_url_link 'http://www.mediafire.com/?'.$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
        
    $mf_file_name $loadxml_folder_info->folder_info->files->file[$i]->filename;
        
    $output .= '<a href="'.$mf_url_link.'" target="_blank" class="downloadBtn"><span><strong>'.$mf_file_name.'</strong></span></a><br />';
    }
    echo 
    $output;
    ?>
    As you can see, the files are shown perfectly, but the problem is that I want them sorted alphabetically... and I am not that good with PHP... so any help is welcomed
    Mr. Goodie2Shoes Reviewed by Mr. Goodie2Shoes on . MediaFire API: want to sort... Hello again, I am using MediaFire's API to share my stuff... I just post the folder link and the files are automatically parsed... and this is the code snippet that I use (including an example): <?php $loadxml_folder_info = simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci'); $max = $loadxml_folder_info->folder_info->file_count; $output = ''; for ($i = 0; $i < $max; $i++) { $mf_url_link = Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    wscripts.net damnlolscript.com lulzjet.com
    Here:

    PHP Code: 
    <?php
    function sortmulti ($array$index$order$natsort=FALSE$case_sensitive=FALSE) {
            if(
    is_array($array) && count($array)>0) {
                foreach(
    array_keys($array) as $key)
                
    $temp[$key]=$array[$key][$index];
                if(!
    $natsort) {
                    if (
    $order=='asc')
                        
    asort($temp);
                    else   
                        
    arsort($temp);
                }
                else
                {
                    if (
    $case_sensitive===true)
                        
    natsort($temp);
                    else
                        
    natcasesort($temp);
                if(
    $order!='asc')
                    
    $temp=array_reverse($temp,TRUE);
                }
                foreach(
    array_keys($temp) as $key)
                    if (
    is_numeric($key))
                        
    $sorted[]=$array[$key];
                    else   
                        
    $sorted[$key]=$array[$key];
                return 
    $sorted;
            }
        return 
    $sorted;
    }
    $loadxml_folder_info simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
    $max $loadxml_folder_info->folder_info->file_count;
    $output '';
    for (
    $i 0$i $max$i++) {
        
    $mf_url_link 'http://www.mediafire.com/?'.$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
        
    $mf_file_name $loadxml_folder_info->folder_info->files->file[$i]->filename;
        
    $links[$i]['url'] = $mf_url_link;
        
    $links[$i]['filename'] = $mf_file_name;
    }
    $links sortmulti($links,'filename','asc',true,true);
    foreach(
    $links as $link$output .= '<a href="'.$link['url'].'" target="_blank" class="downloadBtn"><span><strong>'.$link['filename'].'</strong></span></a><br />';
    echo 
    $output;
    ?>

  4.     
    #3
    Member
    Website's:
    UmNotaBlogger.com
    awesome! thanks!
    I found another way myself:
    PHP Code: 
    <?php
    function sortByOneKey(array $array$key$asc true) {
        
    $result = array();
           
        
    $values = array();
        foreach (
    $array as $id => $value) {
            
    $values[$id] = isset($value[$key]) ? $value[$key] : '';
        }
           
        if (
    $asc) {
            
    asort($values);
        }
        else {
            
    arsort($values);
        }
           
        foreach (
    $values as $key => $value) {
            
    $result[$key] = $array[$key];
        }
           
        return 
    $result;
    }

    $loadxml_folder_info simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
    $max $loadxml_folder_info->folder_info->file_count;
    $output '';
    $array = array();
    for (
    $i 0$i $max$i++) {
        foreach(
    $loadxml_folder_info->folder_info->files->file[$i]->quickkey as $mf_quickkey){
            
    $subarray = array();
            
    $subarray['key'] = (string)$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
            
    $subarray['name'] = (string)$loadxml_folder_info->folder_info->files->file[$i]->filename;
        }
        
    $array[] = $subarray;
    }
    $sortedByNameAsc sortByOneKey($array'name');
    ?>
    but I guess yours is better and less complicated

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. LulzImg API (sort of) Upload Example
    By Lifetalk in forum Web Development Area
    Replies: 4
    Last Post: 10th Dec 2011, 02:59 PM
  2. Sort Thread By...
    By itsHERO in forum vBulletin
    Replies: 1
    Last Post: 20th Oct 2011, 05:47 PM
  3. Replies: 2
    Last Post: 21st Jul 2010, 08:02 PM
  4. How to sort MegaUpload links with RapidLeech?
    By MadK in forum Technical Help Desk Support
    Replies: 10
    Last Post: 27th May 2010, 08:39 AM
  5. [phpBB2] How to sort this?
    By pi0tr3k in forum phpBB
    Replies: 8
    Last Post: 2nd Apr 2010, 03:24 PM

Tags for this Thread

BE SOCIAL