Get result from multiple array?
$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)),
);
I try to get the widths
and algins
colors
as array like this
$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'];
}
That's it :)
$widths = array();
$aligns = array();
foreach($row_properties as $row){
$widths[] = $row['width'];
$aligns[] = $row['align'];
}
精彩评论