Write into array dynamically
Posted: Thu Nov 05, 2009 6:01 pm
Hi quys, i use php datagrid free version and i'm trying to customize dynamically the view mode, my question stems from that but i think is general. Specifically there is a protected function that accepts an array as argument, this array has the following format
In my application the fields are set dynamically from an uploaded file, so the above is useless. Because of that i've saved into an array the fields and with the following i was hoping to solve it
But all i get by this way, is the last column ($b[n]), i placed the call of the function inside the loop before "}" but i get the same. It seems that something i'm doing wrong, i'm stack on it. The last thing i tried is to write into array like the following like writing in a variable without loosing the previous value I did that in order to be similar to format which plays (1.) but i didn't make it, so any ideas would be helpful, thanks in advance!
*I 've already cheched SQL statements, all the other operations works fine, the only problem is on display the data.
Code: Select all
//1.
$a = array(
"field1" =>array("header" =>"x", "type"=>"label",...),
"field2" =>array("header" =>"y", "type"=>"label",...),
........);
Code: Select all
for( $i=0; $i<=$n; $i++)
{ $a[$i] = array("$b[$i]" =>array("header" => "$b[$i]",.........) ); }
// passing array as argumnet in function
$dgrid->setColumnsInViewMode($a);But all i get by this way, is the last column ($b[n]), i placed the call of the function inside the loop before "}" but i get the same. It seems that something i'm doing wrong, i'm stack on it. The last thing i tried is to write into array like the following
Code: Select all
$a = array( ";
Code: Select all
$a="abc"; $a.="def"; //prints abcdef*I 've already cheched SQL statements, all the other operations works fine, the only problem is on display the data.