当涉及到多维数组以及如何推送时,我在理解 PHP 中的编码时遇到了一些麻烦。这个想法是推动一个“属性”和一个“属性值”
我试过下面的公式
   $i = 0;
   $array = array();
    foreach($node as $a)
    {
        $strAtt = $node->PROP[$i]->attributes();
        $strVal = $node->PROP[$i]->PVAL;
        $output = $output.$strAtt." : ".$strVal."<BR>";
        $array[] = ($strAtt => $strVal);
$array[] = ($ strAtt => $strVal); 没有给我太大的成功。我试过array_push($array, $strAtt => $strVal) - 不走运..
作为一个额外的问题,我如何循环遍历数组并打印我的多维值?
新代码
while ($z->name === 'RECORD')
{
$node = new SimpleXMLElement($z->readOuterXML());
$Print = FALSE;
$output = "";
$i = 0;
foreach($node as $a)
{
    $strAtt = $node->PROP[$i]->attributes();
    $strVal = $node->PROP[$i]->PVAL;
    $output = $output.$strAtt." : ".$strVal."<BR>";
    $array[$strAtt] = $strVal;
    if(($i == 6) && ($node->PROP[$i]->PVAL == $ProductLookup))
    {
        $Print = TRUE;
        $Product = $node->PROP[$i]->PVAL;
    }       
    $i++;
}
if($Print == TRUE) {
    echo $output;
    echo "Product : ".$Product."<br>";
    var_dump($array);
    }
    //print_r($array);
    $print = FALSE;
// go to next <product />
$z->next('RECORD');
}
添加了新代码。出于某种原因,当我转储它时,我的 $array 完全是空的,尽管我的 $Output 充满了文本?