JamesGordon
Programmer
I was using the following code:
This worked okay, only putting a "," if the foreach wasn't at the end of the array.
I then tried to make things better by doing this:
It is the final "if" test that I do not know how to code.
If I print(end($a)) then I get returned "Array".
Am I doing this right in the first place?
James.
Code:
$a = array("col1", "col2");
$txt = "SELECT ";
foreach($a in $acol) {
$txt .= $acol;
if($acol !== end($a)) {
$txt .= ", ";
}
print($acol);
This worked okay, only putting a "," if the foreach wasn't at the end of the array.
I then tried to make things better by doing this:
Code:
$a = array("col1" => array("title"=>"c1title", "hidden"=>false), "col2" => array("title"=>c2title", "hidden"=>true));
$txt = "SELECT ";
foreach($a in $acol=>$value) {
txt .= $acol;
[COLOR=red]if() { /* This test is the problem. */[/color red]
txt .= ", ";
}
}
It is the final "if" test that I do not know how to code.
If I print(end($a)) then I get returned "Array".
Am I doing this right in the first place?
James.