I receive data by JSON and I can read the data and show it by the icons in one big list how they were received. What I want to do is sort the objects by price and display them as icons in two columns on a page.
In one column the free items (price = 0) and in the other column the paid items (price > 0)
I assume I have to use usort (which I don't really understand), but I have no idea, how it would be placed into my existing code and how I could create the divs to show the icons in two columns left and right.
This is my simplified code right now:
$arr = json_decode($jsondata,true);
if ($arr['resultCount'] > '0') {
foreach($arr['results'] as $item) {
$icon = $item['artwork'];
$title = $item['trackName'];
$price = $item['price'];
if ($price == 0 ) {
echo '<div class="iconsearch" style="background-image: url('.$icon.');"><a href="'.$title.'">'.$title.'<img src="images/iconmask.png"/></a></div>';
} else {
echo '<div class="iconsearch" style="background-image: url('.$icon.');"><a href="'.$title.'">'.$title.'<img src="images/iconmask.png"/></a></div>';
}
}
}