我得到的所有的標籤和它的外觀像這樣:如何在數組中獲取結果時按值排序?
"testeng" => 0
"testeng1" => 5
所以我想做的事就是爲了這個由值,使第一個是這個值爲5.任何建議,我怎麼能做到這一點?
$tags = ATags::with('articles')->whereHas('language',function($query) use($current_language_id){
$query->where('id','=',$current_language_id);
})->get();
$count_tag = [];
foreach($tags as $tag){
$count_tag[$tag->name] = $tag->articles->count();
}
你能告訴我你從哪裏得到這個 - 「」testeng「=> 0,」testeng1「=> 5' ...? –
$ count_tag [$ tag-> name] = $ tag-> articles-> count(); – None