Results 1 to 3 of 3

Thread: [PHP][XML] Need a bit of help.

  1. #1
    Join Date
    May 2015
    Location
    4f6e2074686520696e7465726e6574
    Posts
    49
    Mentioned
    2 Post(s)
    Quoted
    9 Post(s)

    Default [PHP]Need a bit of help.

    Hello there I've been trying to sort the data I've been pulling from a generated XML file and could use some help with alphabetizing the title_series.

    PHP Code:
    <?php 
    $user
    "domokun1134";

    $urlss =  'http://myanimelist.net/malappinfo.php?u=' $user '&status=all&type=anime';

    $xmlss simplexml_load_file($urlss);
    $jsossn json_encode($xmlss);
    $arrayss json_decode($jsossn,TRUE);

    usort($arrayss, function($a$b){
    return 
    strcasecmp($a[1]["series_title"], $b[1]["series_title"]);
    });

    echo 
    "<pre>";
    print_r($arrayss);
    echo 
    "</pre>";

    ?>
    Last edited by Garden of Sinners; 07-24-2016 at 09:18 PM.

  2. #2
    Join Date
    May 2011
    Location
    In an Island.
    Posts
    1,413
    Mentioned
    2 Post(s)
    Quoted
    149 Post(s)

    Default

    Quote Originally Posted by Garden of Sinners View Post
    Hello there I've been trying to sort the data I've been pulling from a generated XML file and could use some help with alphabetizing the title_series.

    PHP Code:
    <?php 
    $user
    "domokun1134";

    $urlss =  'http://myanimelist.net/malappinfo.php?u=' $user '&status=all&type=anime';

    $xmlss simplexml_load_file($urlss);
    $jsossn json_encode($xmlss);
    $arrayss json_decode($jsossn,TRUE);

    usort($arrayss, function($a$b){
    return 
    strcasecmp($a[1]["series_title"], $b[1]["series_title"]);
    });

    echo 
    "<pre>";
    print_r($arrayss);
    echo 
    "</pre>";

    ?>
    I'm working on something similar to that, but in my case i have a json file, not an xml. And since you want to decode an XML, why you using json_encode and json_decode?

    edit: oh I see..
    ''If you want something you've never had, you have to do something you've never done''


    total leve 2715/1b exp +... exterminated.

  3. #3
    Join Date
    Jun 2014
    Posts
    463
    Mentioned
    27 Post(s)
    Quoted
    229 Post(s)

    Default

    use the PHP function

    Code:
    Sort($array);
    in your case:
    Code:
    <?php  
    $user= "domokun1134"; 
    
    $myURL =  'http://myanimelist.net/malappinfo.php?u=' . $user . '&status=all&type=anime'; 
    
    $xmlLoadFile = simplexml_load_file($myURL); 
    $jEncode = json_encode($xmlLoadFile); 
    $jDecode = json_decode($jEncode,TRUE); 
    sort($jDecode);
    
    foreach ($jDecode as $key => $val) {
        echo('<pre>'.$val.'</pre>\n');
    }
    
    ?>
    correct me if I am wrong, but that should work for listing it in alphabetical order..
    Last edited by Lucidity; 08-02-2016 at 05:52 PM.
    Tsunami

Thread Information

Users Browsing this Thread

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

Posting Permissions

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