Hi guys. This one should be really simple but I've got a mental block on it and would really appreciate some help.
I'm using some classes from an existing open source class EZPDF to format a table, and their syntax for doing so is like this (here's an example .. here we take an array called $data with fields 'Date', 'Name' and 'Postcode' and assign widths to the columns)
$pdf->ezTable($data,'','',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,
'cols'=>array('Date'=>array('width'=>120),
'Name'=>array('width'=>100),
'Postcode'=>array('width'=>80))
));
Well, that looked a little bit too much work for my lazy brain, so I decided to extend the class and write a new function which basically read in all the data keys and matched them to an array of widths and then did the same thing. But with more convenient shorthand for me !
So here's how I approached it :
function basictableformat($data, $widthsarray) {
$basicarray = array();
$i = 0;
foreach ($data[0] as $key=>$value) {
$widthbit = array('width'=>$widthsarray[$i]);
$basicarray[$key] = $widthbit;
$i++;
}
$this->ezTable($data,'','',array('showHeadings'=>1,'shaded'=>1,'showLines'=>1,
'cols'=>array(
$basicarray
)
));
}
However, as you can guess .. this didn't work ! It should be EASY but I've just got a Sunday morning mental block on it. Any help folks is massively appreciated.