dongyinju5977 2013-05-07 23:16
浏览 38

我对如何在foreach循环中使用数组合并感到困惑

Here's my function:

function addr($dfcode)
        {
        return sql::results("select
              A.CODE_,
              case when b.id is null then a.ADDRESS1 else b.addr1 as Address1,
              case when b.id is null then a.ADDRESS2 else b.addr2 as Address2,
              case when b.id is null then a.CITY else b.city as City,
              case when b.id is null then a.STATE_ else b.state as State,
              case when b.id is null then a.ZIP else b.zip as Zip,
              case when b.id is null then a.PHONE else b.phone as Phone,
              case when b.id is null then a.FAX else b.fax as Fax
        from ARE.ADS.DFE a
        left outer join (
              select
                    *
              from ent.dbo.patient_data a
              inner join ent.dbo.doctor_alt_address b on a.doctor_address_id = b.id
              where a.CODE_ =" . $this->patient->hex . "
              and b.doctor_id =" . hexstr($dfcode) . "
              )b on a.CODE_ = b.doctor_id
        where a.CODE_=" . hexstr($dfcode));
        }

I need to array merge the above function into the foreach loop. I'm uncertain on how to do this and i'm really new to array_merge. Below i'm pulling all the doctors information that i need to build a form.

Above is a case where the doctor has an alternate address and that needs to be used if in the array merge if a.doctor_address_id = b.id from the criteria above.

$p->customForm()->log_creation($docname);   

$doctor = new \CRM\Doctor($p->customForm()->dfcode($docname));

foreach ($doctor->getVars() as $k => $v)
    {
    $data['doctor_'. $k] = $v;
    }

foreach ($patient->get_data() as $k=>$v)
    {
    if (is_string($v) || is_numeric($v))
        $data["patient_" . $k] = strtoupper($v);
    }

I hope it's not to confusing, any help would be really appreciated. I hope it's not to vague either. Thank you.

var_dump for $data

Array
(
    [employee] => person
    [date] => 05/08/2013
    [datetime] => 05/08/2013 9:41:15 AM
    [department] => stuff
    [employee_ext] => 7457
    [employee_email] => 
    [barcode] => *NZS01*
    [doctor_df_code] => 09HQ
    [doctor_npi] => 1111111111
    [doctor_dea] => B4574
    [doctor_upin] => 
    [doctor_license] => 
    [doctor_phone] => (111)111-1111
    [doctor_fax] => (000)000-0000
    [doctor_fname] => UNDEFINED
    [doctor_lname] => UNDEFINED
    [doctor_title] => 
    [doctor_intake_rx_caller_id] => 
    [doctor_costco_rx_caller_id] => 
    [doctor_reorder_rx_caller_id] => 
    [doctor_address1] => 24 CABELL st
    [doctor_address2] => SUITE 10
    [doctor_city] => places
    [doctor_state] => CA
    [doctor_zip] => 91111
    [doctor_active_events] => 
    [doctor_dont_call] => 0
    [doctor_dont_fax] => 1
)

Here's the print var for addr()

Array
(
    [0] => Array
        (
            [CODE_] => 09HQ
            [doctor_address1] => alternate addy
            [doctor_address2] => 45854
            [doctor_city] => different city
            [doctor_state] => CA
            [doctor_zip] => 963545
            [doctor_phone] => (619)111-2548
            [doctor_fax] => (157)123-4569
        )

)

if there is an alternate address i need to overwrite it with the array merge addr()

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因