当前位置: 首页>>代码示例>>PHP>>正文


PHP CMbArray::transpose方法代码示例

本文整理汇总了PHP中CMbArray::transpose方法的典型用法代码示例。如果您正苦于以下问题:PHP CMbArray::transpose方法的具体用法?PHP CMbArray::transpose怎么用?PHP CMbArray::transpose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMbArray的用法示例。


在下文中一共展示了CMbArray::transpose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fillFlow

 /**
  * Fill a flow struct
  *
  * @param array      &$array   The flow struct to fill
  * @param CProduct[] $products Products
  * @param int        $n        N*$unit
  * @param string     $start    Start date
  * @param string     $unit     Time unit
  * @param CService[] $services Services
  *
  * @return void
  */
 private static function fillFlow(&$array, $products, $n, $start, $unit, $services)
 {
     foreach ($services as $_key => $_service) {
         $array["out"]["total"][$_key] = array(0, 0);
     }
     $d =& $array["out"];
     // Y init
     for ($i = 0; $i < 12; $i++) {
         $from = CMbDT::date("+{$i} {$unit}", $start);
         $d[$from] = array();
     }
     $d["total"] = array("total" => array(0, 0));
     for ($i = 0; $i < $n; $i++) {
         $from = CMbDT::date("+{$i} {$unit}", $start);
         $to = CMbDT::date("+1 {$unit}", $from);
         // X init
         foreach ($services as $_key => $_service) {
             $d[$from][$_key] = array(0, 0);
             if (!isset($d["total"][$_key])) {
                 $d["total"][$_key] = array(0, 0);
             }
         }
         $d[$from]["total"] = array(0, 0);
         $all_counts = self::getConsumptionMultipleProducts($products, $from, $to, $services, false);
         $by_product = array();
         foreach ($all_counts as $_data) {
             $by_product[$_data["product_id"]][$_data["service_id"]] = $_data["sum"];
         }
         /** @var CProduct $_product */
         foreach ($products as $_product) {
             $counts = CValue::read($by_product, $_product->_id, array());
             $coeff = 1;
             $ref = reset($_product->loadRefsReferences(true));
             if ($ref) {
                 $coeff = $ref->price;
             }
             foreach ($services as $_key => $_service) {
                 $_count = CValue::read($counts, $_key, 0);
                 $_price = $_count * $coeff;
                 $d[$from][$_key][0] += $_count;
                 $d[$from][$_key][1] += $_price;
                 $d[$from]["total"][0] += $_count;
                 $d[$from]["total"][1] += $_price;
                 @($d["total"][$_key][0] += $_count);
                 @($d["total"][$_key][1] += $_price);
                 @($d["total"]["total"][0] += $_count);
                 @($d["total"]["total"][1] += $_price);
             }
         }
     }
     $d = array_map_recursive(array("CProduct", "round2"), $d);
     // Put the total at the end
     $total = $d["total"];
     unset($d["total"]);
     $d["total"] = $total;
     $total = $d["total"]["total"];
     unset($d["total"]["total"]);
     $d["total"]["total"] = $total;
     $d = CMbArray::transpose($d);
 }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:72,代码来源:CProduct.class.php

示例2: foreach

foreach ($aides_antecedent as $type => $_aides_by_type) {
    foreach ($_aides_by_type as $appareil => $_aides_by_appareil) {
        $i = 0;
        $temp_count = 0;
        $count = round(count($_aides_by_appareil) / 4);
        $aides = array();
        foreach ($_aides_by_appareil as $_aide) {
            $aides[$i][] = $_aide;
            $temp_count++;
            if ($temp_count > $count) {
                $temp_count = 0;
                $i++;
            }
        }
        $antecedent->_count_rques_aides_appareil[$type][$appareil] = count($_aides_by_appareil);
        $aides = CMbArray::transpose($aides);
        $aides_antecedent[$type][$appareil] = $aides;
    }
}
$applied_traitements = array();
foreach ($dossier_medical->_ref_traitements as $a) {
    $applied_traitements[$a->traitement] = true;
}
$traitement = new CTraitement();
$traitement->loadAides($user->_id);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("aides_antecedent", $aides_antecedent);
$smarty->assign("antecedent", $antecedent);
$smarty->assign("traitement", $traitement);
$smarty->assign("applied_antecedents", $applied_antecedents);
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:31,代码来源:vw_ant_easymode.php

示例3: testTranspose

 public function testTranspose()
 {
     $array = array(array("val1", "val2", "val3"), array("val1", "val2", "val3"));
     $res = array(array("val1", "val1"), array("val2", "val2"), array("val3", "val3"));
     $this->assertEquals($res, $this->stub->transpose($array));
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:6,代码来源:CMbArrayTest.php


注:本文中的CMbArray::transpose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。