本文整理汇总了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);
}
示例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);
示例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));
}