【发布时间】:2015-08-24 01:47:19
【问题描述】:
$options = array(
array( "title" => "L", "value" => "L"),
array( "title" => "XL", "value" => "XL"),
array( "title" => "S", "value" => "S"),
array( "title" => "M", "value" => "M"),);
$options2 = array(
array( "title" => "S", "value" => "S"),
array( "title" => "M", "value" => "M"),
array( "title" => "L", "value" => "L"),
array( "title" => "XL", "value" => "XL"),);
the final data should be look like:
$options3 = array('S','M','L','XL');
我想按照 $options2 的值重新排列 $options 排序;
案例看起来像php - sort an array by key to match another array's order by key
【问题讨论】:
-
你有没有尝试过,预期的输出是什么?
-
@Rizier123 结果应该和 $options2 一样
-
如果你已经有了
$options2,为什么不能直接使用这个数组呢? -
@Rizier123 $options 是由系统生成的,我无法编辑系统的输出。但是我有 $options2 的标准数据,所以我需要重新排列 $options 看起来像 $options2;
-
是从数据库生成的吗?
标签: php sorting multidimensional-array associative-array