我需要按日期排序多维数组。 数据在称为价格的列中序列化,该列包含几个值:价格和日期。 我在我的控制器中反序列化了这个,我有$ hlisting->价格。 我认为这个价格是一个数组,我是通过价格内的数据价值对所有的价格进行排序。 (kind $ hlisting-> prices-> date)。排序多维数组按日期Laravel
这可能是有益的代码。
<div class="price-dates">
@if(!empty($hlisting->prices))
@foreach($hlisting->prices as $prices)
<div class="price-date">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Period</label>
{!! Form::text('prices_dates[]', $prices['date'], array('class' => 'date-range form-control')) !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Value</label>
{!! Form::text('prices_values[]', $prices['value'], array('class' => 'numeric form-control')) !!}
</div>
</div><!--col-->
<div class="col-sm-1">
<div class="form-group">
<label>Del</label>
<button type="button" class="del-price-date btn btn-sm btn-danger">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
</div><!--row-->
</div>
@endforeach
@else
<div class="price-date">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label>Period</label>
{!! Form::text('prices_dates[]', NULL, array('class' => 'date-range form-control')) !!}
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<label>Value</label>
{!! Form::text('prices_values[]', NULL, array('class' => 'numeric form-control')) !!}
</div>
</div><!--col-->
</div><!--row-->
</div>
@endif
</div>
我想我应该在发送$ hlisting到视图的控制器中进行排序。
感谢
[PHP分类由含有日期元件多维数组(https://stackoverflow.com/questions/2910611/php-sort-a-multidimensional-array-by-element-containing-date) – BenRoob
EDIT的可能的复制:我不需要排序$ hlisting但只有hlisting- $>价格(即containes值和日期) – FranCode
对不起这是一个对象不是一个数组 – FranCode