0

Here I have a set of arrays that print out data in column format, it works fine. What I am having trouble with is the proper syntax for adding an if statement to enable or disable the writing of a particular array if their value meets a condition. Here is my code I'm using to print the columns of data.

foreach ($looper as $key => $value) {
echo '<tr><td>' 
. implode('</td><td>', $wages_out[$key]) . 
'<td>'  . implode('</td><td>', $ss_out[$key]) .
'<td>' . implode('</td><td>', $pension_out[$key]) . 
'<td>' . implode('</td><td>', $rental_out[$key]) . 
'<td>' . implode('</td><td>', $inv_out[$key]) . 
'<td>' . implode('</td><td>', $rider_out[$key]) .
'<td>' . implode('</td><td>', $other_out[$key]) .
'</td></tr>';

}


echo "</table>";

The if statement should look something like this..

if($wages_t != '0.00'){
. implode('</td><td>', $wages_out[$key]) . }

and I need the if statement for each array above. Im doing this to prevent the array from printing if their are no real values in it. I fooled around with the structure for a while but keep getting errors, it doesn't like the if statement in there and any way i try to nest it just won't work. Any help tackling this would be great. Thank you.

Andrew Brown
  • 125
  • 14
  • Where does $wages_t come from? Why do you have to do it for each line if $wages_t is only defined once? And wouldn't you want to still print out if it had '0.00'? – Evadecaptcha Jul 29 '15 at 23:44
  • $wages_t is a variable that does an array sum on the array. In my opinion if its all zeros, it means it doesn't exist, therefor its not necessary to display. – Andrew Brown Jul 29 '15 at 23:53

0 Answers0