我有这种类型的数组,我想得到cid,totalDistance等的值......
并且可以有多个 cid,totalDistance等,那么如何使用循环以表格格式显示值?
Array ( [0] => Array ( [cid] => 6362165 [totalDistance] => 13.727617595403 [totalTrips] => 17 [avgSpeed] => 4.1792097792906 [avgSt] => 1446460214749 [avgEt] => 1446460795802 [avgScore] => 56 [tripIds] => Array ( [0] => 230529 [1] => 230531 [2] => 230527 [3] => 230528 [4] => 230524 [5] => 230526 [6] => 230520 [7] => 230521 [8] => 230522 [9] => 230523 [10] => 230525 [11] => 230530 [12] => 230532 [13] => 230533 [14] => 230534 [15] => 230535 [16] => 230536 ) )
采用此格式
cid totalDistance totalTrips avgspeed avgSt avgEt avgScore tripIds val1 val2 val3 val4 val5 val6 val7 val8
这些值可能更多取决于包含值的数组。
答案 0 :(得分:0)
我不知道我是否理解这个问题。但正如我所理解的那样,只有正常的$routes = array(
array(
'cid' => 1,
'totalDistance' => 13.727617595403,
'totalTrips' => 17,
'avgSpeed' => 4.1792097792906,
'avgSt' => 1446460214749,
'avgEt' => 1446460795802,
'avgScore' => 56,
'tripIds' => array(
),
),
array(
'cid' => 2,
'totalDistance' => 13.727617595403,
'totalTrips' => 17,
'avgSpeed' => 4.1792097792906,
'avgSt' => 1446460214749,
'avgEt' => 1446460795802,
'avgScore' => 56,
'tripIds' => array(
),
));
循环。
PHP:
<table>
<thead>
<tr>
<td>cid</td>
<td>totalDistance</td>
<td>totalTrips</td>
<td>avgSpeed</td>
<td>avgSt</td>
</tr>
</thead>
<tbody>
<?php foreach($routes as $route): ?>
<tr>
<td><?php echo $route['cid']; ?></td>
<td><?php echo $route['totalDistance']; ?></td>
<td><?php echo $route['totalTrips']; ?></td>
<td><?php echo $route['avgSpeed']; ?></td>
<td><?php echo $route['avgSt']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
HTML:
UITableViewCell
Mybe你应该考虑使用一个对象而不是一个数组,但那是你的选择