Good day to those smarter than me. I've been all over google and here to no avail. Here's my situation... I have a json file with this:
{
"firstset": {
"xgroup": [
{
"order": 3,
"title": "third in xgroup"
}, {
"order": 5,
"title": "fifth in xgroup"
}, {
"order": 4,
"title": "fourth in xgroup"
}, {
"order": 1,
"title": "first in xgroup"
}, {
"order": 2,
"title": "second in xgroup"
}
]
},
"secondset": {
"ygroup": [
{
"order": 7,
"title": "seventh in ygroup"
}, {
"order": 4,
"title": "fourth in ygroup"
}, {
"order": 6,
"title": "sixth in ygroup"
}, {
"order": 1,
"title": "first in ygroup"
}, {
"order": 3,
"title": "third in ygroup"
}, {
"order": 2,
"title": "second in ygroup"
}, {
"order": 8,
"title": "eighth in ygroup"
}, {
"order": 5,
"title": "fifth in ygroup"
}
]
}
}
and this is the PHP:
$json_url = "js/testlist.json";
$json = file_get_contents($json_url);
$data = json_decode($json, TRUE);
echo '<ul>';
foreach ($data['firstset']['xgroup'] as $val) {
echo '<li>' . $val['order'] . '.) ' . $val['title'] . '</li>';
}
echo '</ul>';
I've tried everything from the old fashioned 'my_sort' functions found on here to just usorting the entire array with no avail. Is there a way to sort by the 'order' field on the 'firstset' array and display the data?
Thank you in advance...