从查询结果中打印多维数组

时间:2014-11-15 08:57:33

标签: php mysql arrays foreach while-loop

我有一个数组: -

$resolution = array();
foreach ($report as $key => $val) {
    $queryToGetRes = "SELECT resolution,ticket_no FROM techzilla.bugs WHERE bug_id = '$val' ";
    $sqlResult = mysql_query($queryToGetRes) or die (mysql_error());
    while ($resolutionAns = mysql_fetch_array($sqlResult)) {
             $resolution[$resolutionAns['resolution']][] = $resolutionAns['ticket_no'];
    }
  }

我需要打印存储分辨率和票号的数组

2 个答案:

答案 0 :(得分:1)

尝试这样的事情:

echo "<pre>" . print_r($resolution, true) . "</pre>";

答案 1 :(得分:0)

出于调试目的,您应该使用

var_dump($resolution);

如果你想使用它

foreach ($resolution as $r => $ids){
    echo "Resolution : $r\n";
    foreach ($ids as $id) {
        echo "$id\n";
    }
}