二维数组在二维数组中的php。

时间:2022-10-24 22:30:06

Is it possible to achieve something like this? A two-dimensional array containing two-dimensional jagged array?

有可能实现这样的目标吗?一个二维数组,包含二维交错数组?

$jobOrder = array(array(1, "Web Developer", 100, 
                        array(array(1, "PHP", 1),
                              array(2, "HTML", 1), array(3, "JAVA", 1)),
                        array(array(1, "pleasing personality", 1), 
                              array(2, "english skills", 1)), 0), 
                 array(2, "Senior Programmer", 50, 
                       array(array(3, "Phython", 1), 
                             array(5, "RUBY", 1), 
                             array(10, "c#", 1)), 
                       array(array(5, "good social skills", 1), 
                             array(11, "management skills", 1))));

I want to store Job Order details into an array that should contain an orderID, job title, number of openings, skills(may have multiple skills so stored in an array; 2-d because I also wanted to store skillID, skill name and flag: if its been removed or not), qualifications(may have multiple qualifications same with skills), requirements and benefits (also same with skills). I would like to know how to access it.

我想将工作订单的细节存储到一个数组中,该数组应该包含orderID、作业标题、空缺数量、技能(可能有多个技能,所以存储在数组中;2-d因为我也想要存储skillID,技能名称和标志:如果它被移除或不被删除),资格证书(可能具有相同的技能),要求和好处(同样的技能)。我想知道如何使用它。

2 个解决方案

#1


0  

You can access element like this:

您可以访问如下元素:

$jobOrder = array(array(1, "Web Developer", 100, 
                        array(array(1, "PHP", 1),
                              array(2, "HTML", 1), array(3, "JAVA", 1)),
                        array(array(1, "pleasing personality", 1), 
                              array(2, "english skills", 1)), 0), 
                 array(2, "Senior Programmer", 50, 
                       array(array(3, "Phython", 1), 
                             array(5, "RUBY", 1), 
                             array(10, "c#", 1)), 
                       array(array(5, "good social skills", 1), 
                             array(11, "management skills", 1))));

 print_r($jobOrder[0][3]);

I will print the array and also you can access the elements in the array also by adding further indexes.

我将打印数组,也可以通过添加更多索引来访问数组中的元素。

#2


0  

Yes It is possible as you can store number of array rows in the array: means you can add number of rows as well number of elements inside the array even it may multidimensional array as you defined.

是的,这是有可能的,因为你可以在数组中存储数组的数量:意味着你可以在数组中添加行数,甚至可以在你定义的多维数组中添加元素个数。

#1


0  

You can access element like this:

您可以访问如下元素:

$jobOrder = array(array(1, "Web Developer", 100, 
                        array(array(1, "PHP", 1),
                              array(2, "HTML", 1), array(3, "JAVA", 1)),
                        array(array(1, "pleasing personality", 1), 
                              array(2, "english skills", 1)), 0), 
                 array(2, "Senior Programmer", 50, 
                       array(array(3, "Phython", 1), 
                             array(5, "RUBY", 1), 
                             array(10, "c#", 1)), 
                       array(array(5, "good social skills", 1), 
                             array(11, "management skills", 1))));

 print_r($jobOrder[0][3]);

I will print the array and also you can access the elements in the array also by adding further indexes.

我将打印数组,也可以通过添加更多索引来访问数组中的元素。

#2


0  

Yes It is possible as you can store number of array rows in the array: means you can add number of rows as well number of elements inside the array even it may multidimensional array as you defined.

是的,这是有可能的,因为你可以在数组中存储数组的数量:意味着你可以在数组中添加行数,甚至可以在你定义的多维数组中添加元素个数。