PHP implode array issues -


newbie technical difficulty here. hope can explain clearly. in db, have snfreq, snfreq2, snfreqiv, snfreqtube, snfreqtrach, snfreqcath, snfreqwound, , snfreqostomy. wrote isset check each column if data exist, make variable preset text. after checkpoints, wanted include in phrase, don't want include "0" data. reason output still showing multiple commas blank data. here's example output: sn frequency/duration: qd x 60 days + 2 prn visits iv complications, tube feeding complications, , , , < = commas? in db: snfreq = qd x 60 days, snfreq2 = 1, snfreqiv = 1, , snfreqtube = 1, rest null.

    if(isset($rowplanofcare['snfreq'])){$snfreq = "sn frequency/duration: " . $rowplanofcare['snfreq'];}     if(isset($rowplanofcare['snfreq2'])){$snfreq2 = " + 2 prn visits ";}     if(isset($rowplanofcare['snfreqiv'])){$snfreqiv = "iv complications";}     if(isset($rowplanofcare['snfreqtube'])){$snfreqtube = "tube feeding complications";}     if(isset($rowplanofcare['snfreqtrach'])){$snfreqtrach = "tracheostomy care complications";}     if(isset($rowplanofcare['snfreqcath'])){$snfreqcath = "catheter care complications";}     if(isset($rowplanofcare['snfreqwound'])){$snfreqwound = "wound care complications";}     if(isset($rowplanofcare['snfreqostomy'])){$snfreqostomy = "ostomy care complications";}     $snfrequency = $snfreq . $snfreq2 . implode(", ",array($snfreqiv, $snfreqtube, $snfreqtrach, $snfreqcath, $snfreqwound, $snfreqostomy)) . "\n \n "; 

final output should show: sn frequency/duration: qd x 60 days + 2 prn visits iv complications, tube feeding complications < == without other commas.

i hope can me out issues. in advance! :)

try this:

 $snfrequency = $snfreq . $snfreq2 . implode(", ",array_filter(array($snfreqiv, $snfreqtube, $snfreqtrach, $snfreqcath, $snfreqwound, $snfreqostomy))) . "\n \n "; 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -