Advertisement
Guest User

Untitled

a guest
Jun 4th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2.     class Loadxml{
  3.         public function __construct($xmlFile){
  4.             $this->xmlFile = simplexml_load_file($xmlFile);
  5.            
  6.             foreach ($this->xmlFile->song as $song){
  7.                 $this->sort[] = $song;
  8.             }
  9.             // sort the array
  10.             usort($this->sort, function($a, $b){ return $a->category - $b->category; });
  11.         }
  12.        
  13.         public function display(){
  14.             echo'<table border="1">
  15.                    <tr>
  16.                        <td>Title</td>
  17.                        <td>Artist</td>
  18.                        <td>Duration</td>
  19.                        <td>Release</td>
  20.                        <td>Category</td>';
  21.             foreach($this->sort as $new){
  22.                     echo'<tr><td>' . $new->title . '</td>
  23.                    <td>' . $new->artist . '</td>
  24.                    <td>' . $new->duration . '</td>
  25.                    <td>' . $new->release . '</td>
  26.                    <td>' . $new->category . '</td>';
  27.             }
  28.             echo'</tr></table>';
  29.         }
  30.     }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement