Hey Guys!
I need help by sorting the array of playlists. Here my sorting function (working)
So when I try to use it on my script to display playlist include tracks it don't want to work
The Script:
The ouput is still random so no sorting.
Tried to put
on different places but still don't work.
Anyone could help me?
I need help by sorting the array of playlists. Here my sorting function (working)
PHP:
<?php
require("../login.php");
$playlist = $sinusbot->getPlaylists();
$playname = $playlist;
function aasort (&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
aasort($playname,"name");
echo "<pre>";
print_r($playname);
echo "</pre>";
?>
So when I try to use it on my script to display playlist include tracks it don't want to work
The Script:
PHP:
<?php
require("../login.php");
$playlist = $sinusbot->getPlaylists();
for ($a = 0; $a < count($playlist); $a++) {
$playuuid = $playlist[$a]["uuid"];
}
// Sort Array
function aasort (&$array, $key) {
$sorter=array();
$ret=array();
reset($array);
foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key];
}
asort($sorter);
foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii];
}
$array=$ret;
}
aasort($playname,"name");
$divCounter = 1;
for ($a = 0; $a < count($playlist); $a++) {
$playname = $playlist[$a]["name"];
$playuuid = $playlist[$a]["uuid"];
$playlistTracks = $sinusbot->getPlaylistTracks($playuuid);
$playlistTracks = $playlistTracks["entries"];
If($a >= 1) {
echo "<hr/>";
}
echo "
<div class=header>
<a class=collapsing href=# onclick=toggle_visibility('plisttracks$divCounter');>
<div class=collapse>❤</div>
<h2>" . $playname . "</h2>
</a>
</div>";
echo "<div id=plisttracks$divCounter class=plisttracks style=display:none;>";
$divCounter++;
$trackCounter = 1;
for ($i = 0; $i < count($playlistTracks); $i++) {
echo "<div id=filenr>" . $trackCounter . "</div>" . "<div id=filename>" . $playlistTracks[$i]["title"] . '</div>';
$trackCounter++;
//print_r($playlistTracks);
}
echo "</div>";
}
?>
The ouput is still random so no sorting.
Tried to put
PHP:
aasort($playname,"name");
Anyone could help me?