Location: PHPKode > projects > WINR - An iTunes Net Remote > WINR/archive/parseXML_functions.php
<?
$to_display= array("Name", "Time", "Artist", "Album");

function cmp ($a, $b) 
{
	$sort = !empty($_GET["sort_by"]) ? $_GET["sort_by"] : "Artist";
    return strcmp($a[$sort], $b[$sort]);
}

function array_to_table($array, $printable)
{
	$counter = 0;

	$str = "";
	$even = TRUE;

  //expects multi-dimensional array, all with the same keys
  foreach($array as $elem_key=>$element){
  	if ($counter > 200) 
  	{
  		break;
  	}
  	$counter++;
  	
  	if ($even)
  	{
  		$str .= '<div class="listItem-even" onclick="playTrack('.$element['Track ID'].');">';
  	} else 
  	{
  		$str .= '<div class="listItem-odd" onclick="playTrack('.$element['Track ID'].');">';
  	}
  	 
  	$str .= '<div class="column-time">';
	$str .= '<div class="column-artist">';
	$str .= '<div class="column-album">';
	$str .= $element['Album'];
	$str .= '</div>';
	$str .= $element['Artist'];
	$str .= '</div>';
	if ($element['Total Time'] < 3600000) 
	{
		$str .= date('i:s', ($element['Total Time'] / 1000));
	} else 
	{
		$str .= date('G:i:s', ($element['Total Time'] / 1000));
	}
	$str .= '</div>';
	$str .= $element['Name'];
	$str .= '</div>';

	$even = !$even;
  }
  return $str;
} 


function array_to_table2($array, $printable)
{
	$counter = 0;

  //expects multi-dimensional array, all with the same keys
  $first_time=TRUE;
  $str = "<data>\n";
  foreach($array as $elem_key=>$element){
  	if ($counter > 20) {
  		break;
  	}
  	$counter++;
  	
    if($first_time){
		$str .= "<header>";
      $header_itmes=array_keys($element);
      foreach($header_itmes as $header){
          if(in_array($header, $printable)){
          	$str .= "<field>".$header."</field>";
          /*
            $str .= "<th><a href='" . $_SERVER["PHP_SELF"]
            . "?sort_by=" . urlencode($header) . "'>" . $header 
            . "</a></th>\n";
            */
          }
      }
      $str .= "</header>\n";
      $str .= "<songs>\n";
      $first_time=FALSE;
    }
    $str .= "<song>\n";
    foreach($element as $k => $v){
      if(in_array($k, $printable)){
        $str .= "<".$k.">" . $v . "</".$k.">\n";
      }
    }
    $str .= "</song>\n";
  }
  $str .= "</songs>";
  $str .= "</data>";
  return $str;
} 


?>
Return current item: WINR - An iTunes Net Remote