一次调用一些打印功能

时间:2014-12-22 15:34:53

标签: php function printing

我是否知道可以将下面的打印功能组合在一起,以便只调用一次。因为我的listTableOfUser函数在调用时会添加几行数据,而我只需要在打印所有表时添加一次数据。谢谢。

if ($table == "all") {
    print listTableOfUser( "alert", $userNm, $CCR_Trans);
    print listTableOfUser( "problem", $userNm, $CCR_Trans);
    print listTableOfUser( "vitalsigns", $userNm, $CCR_Trans);
    print listTableOfUser( "result", $userNm, $CCR_Trans);
    print listTableOfUser( "medication", $userNm, $CCR_Trans);
    print listTableOfUser( "functional_status", $userNm, $CCR_Trans);
    print listTableOfUser( "procedureP", $userNm, $CCR_Trans);
    print listTableOfUser( "immunization", $userNm, $CCR_Trans);
    print listTableOfUser( "family_history", $userNm, $CCR_Trans);
    print listTableOfUser( "social_history", $userNm, $CCR_Trans);
    print listTableOfUser( "planofcare", $userNm, $CCR_Trans);
    print listTableOfUser( "actor", $userNm, $CCR_Trans);
    print listTableOfUser( "medical_equipment", $userNm, $CCR_Trans);
    print listTableOfUser( "healthcare_provider", $userNm, $CCR_Trans);
    print listTableOfUser( "payers", $userNm, $CCR_Trans);
    print listTableOfUser( "encounters", $userNm, $CCR_Trans);
    print listTableOfUser( "advancedirective", $userNm, $CCR_Trans);
}
else  { print listTableOfUser( $table, $userNm, $CCR_Trans);

1 个答案:

答案 0 :(得分:1)

$tables = ($table == "all") ? array( 
                               "alert",    
                               "problem",
                               "vitalsigns", 
                               "result", 
                               "medication", 
                               "functional_status",
                               "procedureP",
                               "immunization",
                               "family_history",
                               "social_history",
                               "planofcare",
                               "actor",
                               "medical_equipment",
                               "healthcare_provider",
                               "payers",
                               "encounters",
                               "advancedirective"
                             ) : array($table); // prepared an array

foreach ($tables as $t) {
  print listTableOfUser( $t, $userNm, $CCR_Trans );
}