Esempio n. 1
0
 public static function rmKeysArray(array $vals, array $array)
 {
     foreach ($vals as $val) {
         while ($key = Arrays::getKey($val, $array)) {
             unset($this->classes[$key]);
         }
     }
 }
Esempio n. 2
0
 public static function octetConverter($size, $to = 'o', $si = false)
 {
     $to = strtolower($to);
     $units = array('o', 'k', 'm', 'g', 't');
     if (!in_array($to, $units)) {
         exit("Error: {$to} is not an existing unit.");
     }
     $unit = is_numeric($size) ? 'o' : strtolower($size[strlen($size) - 1]);
     $base = $si ? 10 : 2;
     if ($si) {
         $pow = array('o' => 1, 'k' => 3, 'm' => 6, 'g' => 9, 't' => 12);
     } else {
         $pow = array('o' => 1, 'k' => 10, 'm' => 20, 'g' => 30, 't' => 40);
     }
     if (!in_array($unit, $units)) {
         exit("Error: {$unit} is not an existing unit.");
     }
     if ($to === $unit) {
         return $size * 1;
     } else {
         if (Arrays::getKey($to, $units) < Arrays::getKey($unit, $units)) {
             return $size * pow($base, $pow[$unit]);
         } else {
             return $size / pow($base, $pow[$to]);
         }
     }
 }