News新闻

业界新闻动态、技术前沿
Who are we?

您的位置:首页      网络营销      PHP多维数组排序array详解

PHP多维数组排序array详解

PHP数组Array按字段排序/*** Sort array by filed and type, common utility method.* @param array $data* @param string $sort_filed* @param string $sort_type SORT_ASC or SORT_DESC*/public function sortByOneField($data, $filed, $type){if (count($data) = 0)

PHP数组Array按字段排序

  /**
   * Sort array by filed and type, common utility method.
   * @param array $data
   * @param string $sort_filed
   * @param string $sort_type SORT_ASC or SORT_DESC
   */
  public function sortByOneField($data, $filed, $type)
  {
    if (count($data) <= 0) {
      return $data;
    }
    foreach ($data as $key => $value) {
      $temp[$key] = $value[$filed];
    }
    array_multisort($temp, $type, $data);
    return $data;
  }
    我要评论
    共有 人参与,评论 条,顶帖 [点击查看]
  • 验证码:
  • 所有评论仅代表网友意见,与本站立场无关!