$json = json_decode( file_get_contents('json.txt'), true );
$json = sortmulti( $json, 'username', 'asc', );
foreach ($json->data as $item) {
echo $item->username;
echo '<br>';
}
?>
function sortmulti ($array, $index, $order, $natsort=FALSE, $case_sensitive=FALSE)
{
if(is_array($array) && count($array)>0)
{
foreach(array_keys($array) as $key)
$temp[$key]=$array[$key][$index];
if(!$natsort)
{
if ($order=='asc')
asort($temp);
else
arsort($temp);
}
else
{
if ($case_sensitive===true)
natsort($temp);
else
natcasesort($temp);
if($order!='asc')
$temp=array_reverse($temp,TRUE);
}
foreach(array_keys($temp) as $key)
if (is_numeric($key))
$sorted[]=$array[$key];
else
$sorted[$key]=$array[$key];
return $sorted;
}
return $sorted;
}
$(function(){
var plaing_radio = '<? echo $plaing_radio; ?>',
interval = null;
function show( value )
{
$.ajax({
url: "now_plaing_page.php?p=" + value,
cache: false,
success: function(html)
{
$("#now_plaing").html(html);
}
});
}
function runInterval( value )
{
interval = setInterval(function() { show( value ); }, 10000 );
}
function refreshInterval( value )
{
clearInterval( interval );
runInterval( value ) ;
return false;
}
runInterval( plaing_radio ); // забыл добавить что бы таймер сразу начал отсчет
show( plaing_radio );
});
<a href="http://radio1_url:8000/play" onclick="return refreshInterval( 'play' )" class="track track-default">Radio1</a>
<a href="http://radio2_url:8102/ps_128" onclick="return refreshInterval( 'ps_128' )" class="track">Radio2</a>
<a href="?count=/images/123.jpg">Скачать изображение</a>
if( $_GET['count'] && file_exists( $_SERVER['DOCUMENT_ROOT'] ) )
{
//counter ++
file_force_download( $_GET['count'] );
}
function file_force_download($file)
{
if (ob_get_level()) {
ob_end_clean();
}
header('Content-Description: File Transfer');
if (isset($_SERVER['HTTP_USER_AGENT']) and strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{
header('Content-Type: application/force-download');
}
else {
header('Content-Type: application/octet-stream');
}
header('Content-Disposition: attachment; filename=' . basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($_SERVER['DOCUMENT_ROOT'] . $file));
readfile($_SERVER['DOCUMENT_ROOT'] . $file);
exit;
}