我有一个数组
Array (
[bla123] => Array
(
[0] => 2
[1] => 3
[2] => 2
[3] => 2
[4] => 2
[5] => 2
[6] => 2
[7] => 2
[8] => 2
)
[12xye] => Array
(
[0] => 4
[1] => 3
[2] => 3
[3] => 2
[4] => 2
[5] => 4
[6] => 2
[7] => 2
[8] => 2
)
)
如何在php中访问此数组,并在php中获取1,2,3 ..等数量。 逻辑是获得产品的评级。数据完全从数据库中提取,然后使用php进行排序。 例如: 产品1 一颗星:1 两颗星:3 三星级:2 等等... 有点像翻转卡,亚马逊等星系。
答案 0 :(得分:1)
使用以下代码:
<?php
$mainArrDat = array('bla123'=>array('Your_Array_Data_Here'),'12xye'=>('Your_Array_Data_Here'));
foreach( $mainArrDat as $mainArr )
{
foreach($mainArr as $nowArr)
{
//you can access the data that you require from $nowArr
}
}
?>