大家好,我有这个多个数组,但我不知道如何访问这些值我可以获得该公司的所有值,例如我将构建一个具有此值的表,如下所示:是否可能
构建一个嵌套的while循环?
<?php
while (($company_name = current($aCompanys)) !== FALSE ){
echo key($aCompanys).'<br />';
next($aCompanys);
}
?>
[CompanyName1+] => Array (
[Zen] => Array (
[article] => Array (
[0] => Array (
[0] => Kalender
[1] => 9.99
[2] => 2017
)
[1] => Array (
[0] => Notizbuch DINA A4
[1] => 24.99
[2] => 2017
)
)
)
[PlenkS] => Array (
[article] => Array (
[0] => Array (
[0] => Kugelschreiber
[1] => 19.99
[2] => 2017
)
)
)
)
[CompanyName2] => Array (
[asdasd] => Array (
[article] => Array (
[0] => Array (
[0] => Kugelschreiber
[1] => 19.99
[2] => 2017
)
)
)
)
答案 0 :(得分:2)
由于您要将公司名称打印为CompanyName1:Zen,CompanyName2:Plenks
请在下面找到您的阵列的完整代码,它可以正常工作并提供所需的输出。
<?php
$main_array = array("CompanyName"=>array("Zen"=>array("Article"=>array(array('kalendar','9.99','2017'),array('Notizbuch DINA A4','24.99','2017'))),"Plensk"=>array("Article"=>array(array('Kugelschreiber','9.99','2017')))),"CompanyName2"=>array("Zen2"=>array(1,2,3),"Plensk2"=>array(1,2,3)));
var_dump($main_array);
echo "<br /><br />";
foreach ($main_array as $i => $values){
foreach ($values as $key => $t){
echo $i . ":" . $key . "<br />";
}
}
?>
答案 1 :(得分:1)
您可以访问它们,例如:
$aCompanys[CompanyName1+][Zen][article][0][2];
获得此值:&#34; 2017&#34;