Home > Backend Development > PHP Tutorial > php 数组解决办法

php 数组解决办法

WBOY
Release: 2016-06-13 10:27:15
Original
975 people have browsed it

php 数组
Array
(
  [0] => Array
  (
  [category_id] => 15
  [category_name] => 14inch
  [parent_category_id] => 1
  [parent_name] => ホイール?タイヤセット
  )

  [1] => Array
  (
  [category_id] => 16
  [category_name] => 15inch
  [parent_category_id] => 1
  [parent_name] => ホイール?タイヤセット
  )

  [2] => Array
  (
  [category_id] => 17
  [category_name] => 16inch
  [parent_category_id] => 1
  [parent_name] => ホイール?タイヤセット
  )

  [3] => Array
  (
  [category_id] => 18
  [category_name] => 17inch
  [parent_category_id] => 1
  [parent_name] => ホイール?タイヤセット
  )

  [4] => Array
  (
  [category_id] => 36
  [category_name] => SUV
  [parent_category_id] => 2
  [parent_name] => 輸入タイヤ 単品
  )

  [5] => Array
  (
  [category_id] => 37
  [category_name] => VAN
  [parent_category_id] => 2
  [parent_name] => 輸入タイヤ 単品
  )

  [6] => Array
  (
  [category_id] => 42
  [category_name] => 16inch
  [parent_category_id] => 87
  [parent_name] => 国産タイヤ 単品
  )

  [7] => Array
  (
  [category_id] => 43
  [category_name] => 17inch
  [parent_category_id] => 87
  [parent_name] => 国産タイヤ 単品
  )

  [8] => Array
  (
  [category_id] => 82
  [category_name] => 24inch
  [parent_category_id] => 2
  [parent_name] => 輸入タイヤ 単品
  )

)

按照 parent_category_id 他的值进行分组。
比如:
Array
(
  [0] => Array
  ( [0] => Array
(
[category_id] => 15
[category_name] => 14inch
[parent_category_id] => 1
[parent_name] => ホイール?タイヤセット
)

[1] => Array
(
[category_id] => 16
[category_name] => 15inch
[parent_category_id] => 1
[parent_name] => ホイール?タイヤセット
)

[2] => Array
(
[category_id] => 17
[category_name] => 16inch
[parent_category_id] => 1
[parent_name] => ホイール?タイヤセット
)

[3] => Array
(
[category_id] => 18
[category_name] => 17inch
[parent_category_id] => 1
[parent_name] => ホイール?タイヤセット
)
  )

  [1] => Array
  (
  [0] => Array
(
[category_id] => 36
[category_name] => SUV
[parent_category_id] => 2
[parent_name] => 輸入タイヤ 単品
)

[1] => Array
(
[category_id] => 37
[category_name] => VAN
[parent_category_id] => 2
[parent_name] => 輸入タイヤ 単品
)
[2] => Array
(
[category_id] => 82
[category_name] => 24inch

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template