新手技术难度在这里。 希望我能清楚地解释清楚。 在我的数据库中,我有snFreq,snFreq2,snFreqIV,snFreqTube,snFreqTrach,snFreqCath,snFreqWound和snFreqOstomy。 如果数据存在,我写了一个isset来检查每一列,然后使用预设文本创建一个变量。 在所有检查点之后,我想将其包含在一个短语中,但不希望包含“0”数据。由于某种原因,我的输出仍然显示多个带空白数据的逗号。 这是一个示例输出: SN频率/持续时间:QD X 60天+ 2次PRN访问IV并发症,管饲喂复杂,,,,< =有额外的逗号? 在我的DB中: snFreq = QD X 60天,snFreq2 = 1,snFreqIV = 1,snFreqTube = 1,其余为空。
if(isset($rowPlanOfCare['snFreq'])){$snFreq = "SN FREQUENCY/DURATION: " . $rowPlanOfCare['snFreq'];}
if(isset($rowPlanOfCare['snFreq2'])){$snFreq2 = " + 2 PRN VISITS FOR ";}
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 ";
最终输出应仅显示:SN频率/持续时间:QD X 60天+ 2个PRN访问IV并发症,管喂养并发症< ==没有其他逗号。
我希望你能帮我解决这个问题。提前致谢! :)
答案 0 :(得分:0)
试试这个:
$snFrequency = $snFreq . $snFreq2 . implode(", ",array_filter(array($snFreqIV, $snFreqTube, $snFreqTrach, $snFreqCath, $snFreqWound, $snFreqOstomy))) . "\n \n ";