本文整理匯總了PHP中CMbArray::average方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMbArray::average方法的具體用法?PHP CMbArray::average怎麽用?PHP CMbArray::average使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CMbArray
的用法示例。
在下文中一共展示了CMbArray::average方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
$operations = $ds->loadList($sql);
$old_plagesop = 0;
$old_operation_id = 0;
$nb_oper_par_plage = 0;
$nb_plage[$_prat->user_id] = 0;
$preparation[$_prat->user_id] = array();
foreach ($operations as $keyOp => $curr_op) {
if ($old_operation_id and $old_plagesop == $curr_op["plageop_id"]) {
$testValid = 30 * 60 > $curr_op["sec_entree"] - $operations[$old_operation_id]["sec_sortie"];
$testValid = $testValid && $operations[$old_operation_id]["sec_sortie"] < $curr_op["sec_entree"];
if ($testValid) {
$preparation[$_prat->user_id][] = $curr_op["sec_entree"] - $operations[$old_operation_id]["sec_sortie"];
$nb_oper_par_plage++;
if ($nb_oper_par_plage == 1) {
$nb_plage[$_prat->user_id] = $nb_plage[$_prat->user_id] + 1;
}
}
} else {
$nb_oper_par_plage = 0;
}
$old_operation_id = $keyOp;
$old_plagesop = $curr_op["plageop_id"];
}
if (count($preparation[$_prat->user_id])) {
// Mémorisation des données dans MySQL
$sql = "INSERT INTO `temps_prepa` (`temps_prepa_id`, `chir_id`, `nb_prepa`, `nb_plages`, `duree_moy`, `duree_ecart`)\r\n VALUES (NULL, \r\n '{$_prat->user_id}',\r\n '" . count($preparation[$_prat->user_id]) . "',\r\n '" . $nb_plage[$_prat->user_id] . "',\r\n '" . strftime("%H:%M:%S", CMbArray::average($preparation[$_prat->user_id])) . "',\r\n '" . strftime("%H:%M:%S", CMbArray::variance($preparation[$_prat->user_id])) . "');";
$ds->exec($sql);
$ds->error();
}
}
echo "Liste des temps de Préparation mise à jour";
示例2: testAverage
public function testAverage()
{
$this->assertEquals(10, $this->stub->average(array(5, 10, 15)));
}