PHP 内爆数组问题

发布于 2024-11-18 09:09:13 字数 1393 浏览 4 评论 0原文

新手技术难度在这里。 希望我能清楚地解释这一点。 在我的数据库中,我有 snFreq、snFreq2、snFreqIV、snFreqTube、snFreqTrach、snFreqCath、snFreqWound 和 snFreqOstomy。 我编写了一个 isset 来检查每一列是否存在数据,然后使用预设文本创建一个变量。 在所有检查点之后,我想将其包含在一个短语中,但不想包含“0”数据。由于某种原因,我的输出仍然显示多个逗号和空白数据。 这是一个示例输出: SN 频率/持续时间:QD X 60 天 + 2 次 PRN 就诊,治疗 IV 并发症、管饲并发症、、、、、< = 带有额外的逗号? 在我的数据库中: snFreq = QD X 60 DAYS、snFreq2 = 1、snFreqIV = 1、snFreqTube = 1,其余均为 Null。

    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 并发症、管饲并发症 < == 没有其他逗号。

我希望你能帮我解决这个问题。提前致谢! :)

Newbie technical difficulty here.
Hope I can explain this clearly.
in My DB, I have snFreq, snFreq2, snFreqIV, snFreqTube, snFreqTrach, snFreqCath, snFreqWound, and snFreqOstomy.
I wrote an isset to check each column if data exist, then make a variable with preset text.
After all the checkpoints, I wanted to include this in a phrase, but don't want to include the "0" data. For some reason my output is still showing multiple commas with blank data.
Here's an example output:
SN FREQUENCY/DURATION: QD X 60 DAYS + 2 PRN VISITS FOR IV COMPLICATIONS, TUBE FEEDING COMPLICATIONS, , , , < = with extra commas?
In my DB:
snFreq = QD X 60 DAYS, snFreq2 = 1, snFreqIV = 1, and snFreqTube = 1, the rest are Null.

    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 ";

Final Output should only show: SN FREQUENCY/DURATION: QD X 60 DAYS + 2 PRN VISITS FOR IV COMPLICATIONS, TUBE FEEDING COMPLICATIONS < == without the other commas.

I hope you can help me out with this issues. Thanks in advance! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飘逸的'云 2024-11-25 09:09:13

试试这个:

 $snFrequency = $snFreq . $snFreq2 . implode(", ",array_filter(array($snFreqIV, $snFreqTube, $snFreqTrach, $snFreqCath, $snFreqWound, $snFreqOstomy))) . "\n \n ";

Try this:

 $snFrequency = $snFreq . $snFreq2 . implode(", ",array_filter(array($snFreqIV, $snFreqTube, $snFreqTrach, $snFreqCath, $snFreqWound, $snFreqOstomy))) . "\n \n ";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文