Esempio n. 1
0
File: Dev.php Progetto: elemenofi/lb
 public static function GET__Query__Debug($Query, $Object)
 {
     foreach ($Object as $Key => $Value) {
         if (ccTXT__Type::Value__('Has_Digits__Only__Ignore_Signs', $Value) === false) {
             $Value = "'" . $Value . "'";
         }
         $Query = str_replace(':in' . $Key, $Value, $Query);
     }
     return $Query;
 }
Esempio n. 2
0
File: TXT.php Progetto: elemenofi/lb
 public static function FIND___Combinations__By_Sum($Array, $SUM___Limit)
 {
     // remove items greater than $SUM___Limit
     $Array_01 = array_filter($Array, function ($Value) use($SUM___Limit) {
         return $Value <= $SUM___Limit;
     });
     rsort($Array_01);
     // the algorithm is usable if the number of elements is less than 20 (because set_time_limit)
     $N_Array_01 = count($Array_01);
     //The total number of possible combinations
     $Total_Combinations = pow(2, $N_Array_01);
     $Out = array();
     // algorithm from http://r.je/php-find-every-combination.html
     // loop through each possible combination
     for ($i = 0; $i < $Total_Combinations; $i++) {
         $iCombination = array();
         // for each combination check if each bit is set
         for ($j = 0; $j < $N_Array_01; $j++) {
             // is bit $j set in $i?
             if (pow(2, $j) & $i) {
                 $iCombination[] = $Array_01[$j];
             }
         }
         $SUM___Combination = array_sum($iCombination);
         $bAre_Equal = ccTXT__Type::FLOATS___Are_Equal($SUM___Combination, $SUM___Limit);
         if ($bAre_Equal === true) {
             $Out[] = $iCombination;
         }
     }
     return $Out;
 }
Esempio n. 3
0
 public static function PARSE___Volume($Value)
 {
     $Matches = explode("x", $Value);
     if (count($Matches) === 2) {
         $Value_02 = $Matches[1];
     } else {
         $Value_02 = $Matches[0];
     }
     $Value_Casted = ccTXT__Type::PARSE__FLOAT($Value_02);
     if ($Value_Casted === false) {
         $Value_Casted = ccTXT__Type::PARSE__FLOAT($Value_02);
     }
     return $Value_Casted;
 }