从多个数组获取结果


$row_properties = array(
     "Header 1"=>array("width"=>20,"align"=>'C',"colors"=>array(100,220,255)),
     "Header 2"=>array("width"=>20,"align"=>'C',"colors"=>array(100,220,255)),
     "Header 3"=>array("width"=>20,"align"=>'C',"colors"=>array(100,220,255)),
);

我尝试像这样将widthsalgins colors作为数组

$widths = array(20,20,20);
$aligns  = array("C","C","C")
$colors  array(array(100,220,255),array(100,220,255),array(100,220,255));
$widths = $aligns = $colors = array();
foreach ($row_properties as $prop) {
  $widths[] = $prop['width'];
  $aligns[] = $prop['align'];
  $colors[] = $prop['color'];
}
$widths = array();
$aligns = array();
$colors = array();
foreach($row_properties as $property) {
    $widths[] = $property['width'];
    $aligns[] = $property['align'];
    $colors[] = $property['colors'];
}

就是这样:)

$widths = array();
$aligns  = array();
foreach($row_properties as $row){
   $widths[] = $row['width'];
   $aligns[] = $row['align'];
}

相关内容

  • 没有找到相关文章

最新更新