Rumah > pembangunan bahagian belakang > tutorial php > php 数组解决办法

php 数组解决办法

WBOY
Lepaskan: 2016-06-13 10:27:15
asal
960 orang telah melayarinya

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

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan