我有一個配置變量,它使用foreach循環來打印出所有對象。有沒有辦法根據日期排序打印出來? 這是我打印出的對象的代碼。我想根據$press['date']
根據laravel中的日期排序配置變量
@foreach (config('constants.pressMetadata') as $press)
<div>
<p id="quote">{{ $press['title'] }}</p>
<div class="more label"><a id="link" href="{{$press['url']}}">-{{$press['company']}}: {{$press['date']}}</a></div>
<hr>
</div>
@endforeach
這裏對它進行排序是constants.pressMetadata
:
'pressMetadata'=>[
"AARP" => [
"id" => 1,
"company" => "AARP",
"title" => "Updating Your Résumé for the Digital Age",
"url" => "http://www.aarp.org/work/job-hunting/info-2016/give-resume-a-digital-reboot.html",
"date" => "Sep 9, 2016"
],
"Business Insider" => [
"id" => 2,
"company" => "Business Insider",
"title" => "8 things you should always include on your résumé",
"url" => "http://www.businessinsider.com/what-to-always-include-on-your-resume-2016-1",
"date" => "Jan 28, 2016"
],
"Morning Journal" => [
"id" => 3,
"company" => "Morning Journal",
"title" => "5 things you missed: Google updates search, Jobscan and more",
"url" => "http://www.morningjournal.com/article/MJ/20140124/NEWS/140129366",
"date" => "Jan 24, 2014"
],
],
[PHP按照含有日期的元素對多維數組進行排序]可能的重複(http://stackoverflow.com/questions/2910611/php-sort-a-multidimensional-array-by-element-containing-date) – mickmackusa
你如果您在發佈問題前未搜索現有答案,則將其作爲資源貶值。看看有多少答案對你有幫助:http://stackoverflow.com/search?q=how+to+sort+multidimensional+array+by+date – mickmackusa
downvoted因爲沒有顯示任何努力的研究和自我解決 – mickmackusa