3

我试图弄清楚如何编写一个返回多维数组的函数。我知道如何使用“category_parent”值编写函数。但我只是想写一个函数,它可以通过只使用左右键来创建多维数组。

array(71) {
  [0]=>
  array(9) {
    ["id"]=>
    string(1) "1"
    ["category_name"]=>
    string(6) "Rubros"
    ["category_parent"]=>
    string(1) "0"
    ["category_slug"]=>
    string(6) "rubros"
    ["category_image"]=>
    NULL
    ["category_totals"]=>
    NULL
    ["category_lft"]=>
    string(1) "1"
    ["category_rgt"]=>
    string(3) "142"
  }
  [1]=>
  array(9) {
    ["id"]=>
    string(4) "1000"
    ["category_name"]=>
    string(12) "Restaurantes"
    ["category_parent"]=>
    string(1) "1"
    ["category_slug"]=>
    string(12) "restaurantes"
    ["category_image"]=>
    string(16) "restaurantes.png"
    ["category_totals"]=>
    string(1) "1"
    ["category_lft"]=>
    string(1) "2"
    ["category_rgt"]=>
    string(2) "13"
  }
  [2]=>
  array(9) {
    ["id"]=>
    string(1) "3"
    ["category_name"]=>
    string(21) "Restaurantes de Campo"
    ["category_parent"]=>
    string(4) "1000"
    ["category_slug"]=>
    string(21) "restaurantes-de-campo"
    ["category_image"]=>
    NULL
    ["category_totals"]=>
    string(1) "1"
    ["category_lft"]=>
    string(1) "3"
    ["category_rgt"]=>
    string(1) "4"
  }
  [3]=>
  array(9) {
    ["id"]=>
    string(2) "37"
    ["category_name"]=>
    string(25) "Restaurantes en la Ciudad"
    ["category_parent"]=>
    string(4) "1000"
    ["category_slug"]=>
    string(19) "restaurantes-ciudad"
    ["category_image"]=>
    string(0) ""
    ["category_totals"]=>
    string(1) "6"
    ["category_lft"]=>
    string(1) "5"
    ["category_rgt"]=>
    string(1) "6"
  }
  [4]=>
  array(9) {
    ["id"]=>
    string(2) "41"
    ["category_name"]=>
    string(21) "Servicios de Catering"
    ["category_parent"]=>
    string(4) "1000"
    ["category_slug"]=>
    string(8) "catering"
    ["category_image"]=>
    string(0) ""
    ["category_totals"]=>
    string(1) "1"
    ["category_lft"]=>
    string(1) "7"
    ["category_rgt"]=>
    string(1) "8"
  }
  [5]=>
  array(9) {
    ["id"]=>
    string(2) "48"
    ["category_name"]=>
    string(10) "Rotiserias"
    ["category_parent"]=>
    string(4) "1000"
    ["category_slug"]=>
    string(10) "rotiserias"
    ["category_image"]=>
    string(0) ""
    ["category_totals"]=>
    string(1) "1"
    ["category_lft"]=>
    string(1) "9"
    ["category_rgt"]=>
    string(2) "10"
  }
  [6]=>
  array(9) {
    ["id"]=>
    string(2) "62"
    ["category_name"]=>
    string(10) "Pizzerías"
    ["category_parent"]=>
    string(4) "1000"
    ["category_slug"]=>
    string(9) "pizzerias"
    ["category_image"]=>
    string(0) ""
    ["category_totals"]=>
    string(1) "1"
    ["category_lft"]=>
    string(2) "11"
    ["category_rgt"]=>
    string(2) "12"
  }
  [7]=>
  array(9) {
    ["id"]=>
    string(1) "2"
    ["category_name"]=>
    string(13) "Profesionales"
    ["category_parent"]=>
    string(1) "1"
    ["category_slug"]=>
    string(13) "profesionales"
    ["category_image"]=>
    string(17) "profesionales.png"
    ["category_totals"]=>
    string(1) "2"
    ["category_lft"]=>
    string(2) "14"
    ["category_rgt"]=>
    string(2) "35"
  }
  [8]=>
  array(9) {
    ["id"]=>
    string(2) "29"
    ["category_name"]=>
    string(11) "Arquitectos"
    ["category_parent"]=>
    string(1) "2"
    ["category_slug"]=>
    string(11) "arquitectos"
    ["category_image"]=>
    NULL
    ["category_totals"]=>
    string(1) "0"
    ["category_lft"]=>
    string(2) "15"
    ["category_rgt"]=>
    string(2) "16"
  }
  [9]=>
  array(9) {
    ["id"]=>
    string(2) "30"
    ["category_name"]=>
    string(8) "Abogados"
    ["category_parent"]=>
    string(1) "2"
    ["category_slug"]=>
    string(8) "abogados"
    ["category_image"]=>
    NULL
    ["category_totals"]=>
    string(1) "6"
    ["category_lft"]=>
    string(2) "17"
    ["category_rgt"]=>
    string(2) "18"
  }
}

任何帮助表示赞赏!

4

1 回答 1

0

您这样做就像从文件中提取数据一样,例如 '["dimensionOne"]["dimensionTwo"]'

于 2014-05-02T20:55:39.290 回答