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


PHP mod函数代码示例

本文整理汇总了PHP中mod函数的典型用法代码示例。如果您正苦于以下问题:PHP mod函数的具体用法?PHP mod怎么用?PHP mod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_month_wct

function get_month_wct($date, $time)
{
    $MONTHS = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    //Go through each month and check if it exists in the date string
    $month = -1;
    for ($i = 0; $i < count($MONTHS); $i++) {
        //Check each month
        if (stripos($date, $MONTHS[$i]) !== false) {
            if ($time == "start") {
                //If the previous month exists in the string
                if (stripos($date, $MONTHS[mod($i - 1, 12)]) !== false) {
                    //This is the correct month
                    $month = mod($i - 1, 12);
                } else {
                    $month = $i;
                }
            } else {
                //If the next month exists in the string
                if (stripos($date, $MONTHS[mod($i + 1, 12)]) !== false) {
                    $month = mod($i + 1, 12);
                } else {
                    $month = $i;
                }
            }
        }
    }
    if ($month == -1) {
        echo "\nMonth was -1";
    }
    return $month + 1;
}
开发者ID:brthiess,项目名称:rockstat_final,代码行数:31,代码来源:wct_event.php

示例2: randomcpf

function randomcpf($compontos)
{
    $n1 = rand(0, 9);
    $n2 = rand(0, 9);
    $n3 = rand(0, 9);
    $n4 = rand(0, 9);
    $n5 = rand(0, 9);
    $n6 = rand(0, 9);
    $n7 = rand(0, 9);
    $n8 = rand(0, 9);
    $n9 = rand(0, 9);
    $d1 = $n9 * 2 + $n8 * 3 + $n7 * 4 + $n6 * 5 + $n5 * 6 + $n4 * 7 + $n3 * 8 + $n2 * 9 + $n1 * 10;
    $d1 = 11 - mod($d1, 11);
    if ($d1 >= 10) {
        $d1 = 0;
    }
    $d2 = $d1 * 2 + $n9 * 3 + $n8 * 4 + $n7 * 5 + $n6 * 6 + $n5 * 7 + $n4 * 8 + $n3 * 9 + $n2 * 10 + $n1 * 11;
    $d2 = 11 - mod($d2, 11);
    if ($d2 >= 10) {
        $d2 = 0;
    }
    $retorno = '';
    if ($compontos == 1) {
        $retorno = '' . $n1 . $n2 . $n3 . "." . $n4 . $n5 . $n6 . "." . $n7 . $n8 . $n9 . "-" . $d1 . $d2;
    } else {
        $retorno = '' . $n1 . $n2 . $n3 . $n4 . $n5 . $n6 . $n7 . $n8 . $n9 . $d1 . $d2;
    }
    return $retorno;
}
开发者ID:rodrigoac,项目名称:Vulnerability-Sending-Sus,代码行数:29,代码来源:sus.php

示例3: mod

function mod($a, $b)
{
    if ($a <= 0) {
        return (int) mod($b - abs($a), $b);
    } else {
        return (int) $a % $b;
    }
}
开发者ID:qquk,项目名称:IBAG,代码行数:8,代码来源:ws.php

示例4: traducirCifra

function traducirCifra($number)
{
    // Mandarlo a que tradusca la cantidad en letra.
    if ($number == 0) {
        // if amount = 0, then forget all about conversions,
        $hundreds_final_string = " cero ";
        // amount is zero (cero). handle it externally, to
        // function breakdown
    } else {
        $millions = whole_part($number, 1000000);
        // first, send the millions to the string
        $number = mod($number, 1000000);
        // conversion function
        if ($millions != 0) {
            // This condition handles the plural case
            if ($millions == 1) {
                // if only 1, use 'millon' (million). if
                $descriptor = " millon, ";
                // > than 1, use 'millones' (millions) as
            } else {
                // a descriptor for this triad.
                $descriptor = " millones, ";
            }
        } else {
            $descriptor = " ";
            // if 0 million then use no descriptor.
        }
        $millions_final_string = string_literal_conversion($millions) . $descriptor;
        $thousands = whole_part($number, 1000);
        // now, send the thousands to the string
        $number = mod($number, 1000);
        // conversion function.
        if ($thousands != 0) {
            // This condition eliminates the descriptor
            $descriptor = " mil, ";
            // if there are no thousands on the amount
        } else {
            $descriptor = " ";
        }
        $thousands_final_string = string_literal_conversion($thousands) . $descriptor;
        // this will handle numbers between 1 and 999 which
        // need no descriptor whatsoever.
        $hundreds = $number;
        $hundreds_final_string = string_literal_conversion($hundreds);
    }
    //end if ($number ==0)
    $millions_final_string = strtoupper($millions_final_string);
    $thousands_final_string = strtoupper($thousands_final_string);
    $hundreds_final_string = strtoupper($hundreds_final_string);
    //$t->set_var("IMPORTE_LETRA",$millions_final_string.$thousands_final_string.$hundreds_final_string." USD 00/100 CTS.");
    $importeLetra = $millions_final_string . $thousands_final_string . $hundreds_final_string;
    return $importeLetra;
}
开发者ID:nesmaster,项目名称:anakosta,代码行数:53,代码来源:eirPdf3.php

示例5: demoMod

function demoMod($a, $b)
{
    echo "Demo for pair ({$a}, {$b}):\n";
    $c = $a / $b;
    $ic = idiv($a, $b);
    $d = $a % $b;
    $mc = div($a, $b);
    $md = mod($a, $b);
    echo "Standard PHP division: {$a}  / {$b} = {$c}\n";
    echo "Custom integer division: {$a} / {$b} = {$ic}\n";
    echo "Fixed integer division: {$a} / {$b} = {$mc}\n";
    echo "Standard PHP integer modulo: {$a} % {$b} = {$d}\n";
    echo "Fixed integer modulo: {$a} mod {$b} = {$md}\n\n";
}
开发者ID:anatoliyrazin,项目名称:negative_base,代码行数:14,代码来源:neg_base.php

示例6: getuptime

function getuptime($var2, $var3)
{
    $r = floor($var2);
    $uptimes = mod($r, 60);
    $r = floor($r / 60);
    $uptimem = mod($r, 60);
    $r = floor($r / 60);
    $uptimeh = mod($r, 24);
    $uptimed = number_format(floor($r / 24));
    if ($var3 == 'server') {
        return '' . $uptimed . 'd ' . $uptimeh . 'h<br>' . $uptimem . 'm ' . $uptimes . 's';
    } else {
        return '' . $uptimed . 'd' . $uptimeh . 'h' . $uptimem . 'm';
    }
}
开发者ID:Sajaki,项目名称:addons,代码行数:15,代码来源:db_inc.php

示例7: AddPoints

function AddPoints($points, $perma = false, $id = false)
{
    global $user;
    if (!$id) {
        $id = $user['id'];
    }
    //echo "Adding ".$points." to user ".$user['username']."<br />";
    if ($points < 0) {
        $sign = "-";
        $points = mod(idstring($points));
    } else {
        $sign = "+";
    }
    if ($perma) {
        $permapart = ", `perma_points` = `perma_points` " . $sign . " '" . idstring($points) . "'";
    }
    doquery("UPDATE {{table}} SET `total_points` = `total_points` " . $sign . " '" . idstring($points) . "'" . $permapart . " WHERE `id` = '" . idstring($id) . "' ;", 'users');
}
开发者ID:sonicmaster,项目名称:RPG,代码行数:18,代码来源:StatFunctions.php

示例8: ModificarPelicula

         }
         if ($HTTP_GET_VARS['accion'] == modificar && isset($HTTP_GET_VARS['id_pelicula'])) {
             ModificarPelicula($HTTP_GET_VARS['id_pelicula']);
         }
         /*if($HTTP_GET_VARS['accion'] == agregar){
         		AgregarPelicula(
         					   limpia($HTTP_POST_VARS['nombre_pelicula']),
         		               limpia($HTTP_POST_VARS['formato']),
         					   limpia($HTTP_POST_VARS['audio'])
         					   );
         		}*/
         if ($HTTP_GET_VARS['accion'] == ver && isset($HTTP_GET_VARS['id_pelicula'])) {
             DetallePelicula($HTTP_GET_VARS['id_pelicula']);
         }
         if ($_GET['accion'] == mod) {
             mod(limpia($_POST['id_pelicula']), limpia($_POST['nombre_pelicula']), limpia($_POST['formato']), limpia($_POST['audio']));
         }
     }
 }
 include "conn.php";
 //conexion a postgresql
 $conn = pg_connect("host={$dbhost} port={$dbport} dbname={$dbname} user={$dbuser} password={$dbpass}") or die("Error al conectar la base de datos");
 $_pagi_sql = "SELECT count(*)\n\t\t\t\t\t\t\t\t\t\t\t  FROM pelicula";
 $_pagi_nav_num_enlaces = 5;
 $_pagi_cuantos = 35;
 $_pagi_mostrar_errores = TRUE;
 $_pagi_nav_estilo = "paginacion";
 $_pagi_propagar = array("");
 include 'paginator.inc.php';
 echo "<center>" . $_pagi_navegacion . "</center>";
 listarPeliculas($_pagi_Lim);
开发者ID:jeldrex,项目名称:BuscaF,代码行数:31,代码来源:listar_peliculas.php

示例9: mod

 public function mod($other)
 {
     return mod($this, $other);
 }
开发者ID:Vinceveve,项目名称:php-rql,代码行数:4,代码来源:misc.php

示例10: mod

<?php

mod("pager");
$user = mysqli_fetch_array(db_query('SELECT * FROM mybb_users WHERE uid="' . $id . '"'));
if (!$user) {
    output_message('Error', 'User not found.');
    exit;
} else {
    function show_left()
    {
        global $user, $count;
        output_block_start($user['username']);
        echo 'Member since ' . date('Y-m-d', $user['regdate']) . '<br/>' . number_format($count) . ' sequences';
        output_block_end();
    }
}
$gp = pager_init(66);
$where = ' WHERE owner="' . $id . '" AND deleted=0 ';
$order = "date DESC";
$countQuery = 'SELECT COUNT(*) AS count FROM sequences' . $where;
$count = db_result(db_query($countQuery), 0);
function display_seq($row)
{
    echo '<div class="game"><a href="/' . $row['id'] . '">' . preview($row['id'], $row['title']) . '</a></div>';
}
output_header('Profile for ' . $user['username']);
output_block_start('Sequences');
if ($count == 0) {
    echo 'No sequences found.';
}
pager_display($gp, 'SELECT * FROM sequences' . $where . ' ORDER BY ' . $order, $countQuery, 'count', 'display_seq');
开发者ID:darwinkim,项目名称:onlinesequencer,代码行数:31,代码来源:members.php

示例11: mod

<?php

mod('form');
$form = form_create('Continue', 'default', 'process_form', 'post');
function process_form()
{
    global $form, $root, $userid;
    $f = $_FILES['file'];
    $name = $f['name'];
    $f['name'] = md5(rand(0, 1000000000));
    $path = $root . '/uploads/midi/' . $f['name'];
    if (!move_uploaded_file($f['tmp_name'], $path)) {
        form_add_error($form, 'Error uploading file.');
    } else {
        header('Location: /import2/' . $f['name'] . '?title=' . urlencode($name));
        exit;
    }
}
form_add_param($form, 'File', 'file', 'file;mid;20000000', '', 100, 14);
form_process();
output_header("Upload MIDI File");
output_block_start("Upload MIDI File");
echo '<p>Keep in mind that not all MIDI files will work well! Many MIDI files use features that are not supported by the sequencer; simple ones work best.</p>';
echo '<p>Examples: <a href="http://onlinesequencer.net/4679">Baba Yetu</a>, <a href="http://onlinesequencer.net/4680">Fangad aven korvring</a>, <a href="http://onlinesequencer.net/4681">Cliffs of Dover</a></p>';
form_display($form);
output_block_end();
output_footer();
开发者ID:darwinkim,项目名称:onlinesequencer,代码行数:27,代码来源:import.php

示例12: define

<?php

define("NOT_IN_FORUM", 1);
include "inc/init.php";
include 'inc/init_forum.php';
include $local . '/pages.php';
mod("page");
include $templates_path . '/' . $settings['template'] . '/main.php';
$form_id = 0;
if (!isset($_GET["x"])) {
    $parts = array('view', '0');
} else {
    $parts = explode("/", $_GET['x']);
}
$page_name = $parts[0];
if (empty($page_name) || preg_match("/\\W/", $page_name)) {
    error_page("No page was specified.");
} else {
    $params = $pages[$page_name]['params'];
    if (count($parts) - 1 < count($params)) {
        error_page('Incorrect URL specified. Did you follow a broken link?');
    }
    $i = 0;
    foreach ($params as $param => $value) {
        $p = urldecode($parts[$i + 1]);
        if (validate($p, $value)) {
            $GLOBALS[$param] = $p;
        } else {
            error_page('Incorrect URL specified. Did you follow a broken link?');
        }
        $i++;
开发者ID:darwinkim,项目名称:onlinesequencer,代码行数:31,代码来源:index.php

示例13: covertirNumLetras

function covertirNumLetras($number)
{
   $millions_final_string="";
   $thousands_final_string="";
  //number = number_format (number, 2);
   $number1=$number.'';
   //settype (number, "integer");
   $cent = explode('.',$number);  
   if (isset($cent[1]) ){
	   $centavos = $cent[1];
	  }else{
	  $centavos = "00";
	  }
   
   $number= $cent[0];
      

   if ($number == 0 || $number == "") 
   { // if amount = 0, then forget all about conversions, 
      $centenas_final_string=" cero "; // amount is zero (cero). handle it externally, to 
      // function breakdown 
  } 
   else 
   { 
   
     $millions  = ObtenerParteEntDiv($number, 1000000); // first, send the millions to the string 
      $number = mod($number, 1000000);           // conversion function 
      
     if ($millions != 0)
      {                      
      // This condition handles the plural case 
         if ($millions == 1) 
         {              // if only 1, use 'millon' (million). if 
            $descriptor= " millon ";  // > than 1, use 'millones' (millions) as 
            } 
         else 
         {                           // a descriptor for this triad. 
              $descriptor = " millones "; 
            } 
      } 
      else 
      {    
         $descriptor = " ";                 // if 0 million then use no descriptor. 
      } 
      $millions_final_string = string_literal_conversion($millions).$descriptor; 
          
      
      $thousands = ObtenerParteEntDiv($number, 1000);  // now, send the thousands to the string 
        $number = mod($number, 1000);            // conversion function. 
      //print "Th:".thousands;
     if ($thousands != 1) 
      {                   // This condition eliminates the descriptor 
         $thousands_final_string =string_literal_conversion($thousands) . " mil "; 
       //  descriptor = " mil ";          // if there are no thousands on the amount 
      } 
      if ($thousands == 1)
      {
         $thousands_final_string = " mil "; 
     }
      if ($thousands < 1) 
      { 
         $thousands_final_string = " "; 
      } 
  
      // this will handle numbers between 1 and 999 which 
      // need no descriptor whatsoever. 

     $centenas  = $number;                     
      $centenas_final_string = string_literal_conversion($centenas) ; 
      
   } //end if (number ==0) 

   /*if (ereg("un",centenas_final_string))
   {
     centenas_final_string = ereg_replace("","o",centenas_final_string); 
   }*/
   //finally, print the output. 

   /* Concatena los millones, miles y cientos*/
   $cad = $millions_final_string.$thousands_final_string.$centenas_final_string; 
   
   /* Convierte la cadena a Mayúsculas*/
   $cad = strtoupper($cad);       

   if (strlen($centavos)>2)
   {   
      if(substr($centavos,2,2)>= 5){
         $centavos = substr($centavos,0,2)+(intval(substr($centavos,1,2))+1);
      }   else{
        $centavos = substr($centavos,0,3);
       }
   }

   /* Concatena a los centavos la cadena "/100" */
   if (strlen($centavos)==1)
   {
      $centavos = $centavos."0";
   }
   $centavos = $centavos. "/100"; 

//.........这里部分代码省略.........
开发者ID:hackdracko,项目名称:Facturacion-Kio,代码行数:101,代码来源:importeco.php

示例14: sy_cnpj

function sy_cnpj($compontos = true, $seed = null)
{
    if (!is_null($seed)) {
        mt_srand($seed);
    }
    $n1 = mt_rand(0, 9);
    $n2 = mt_rand(0, 9);
    $n3 = mt_rand(0, 9);
    $n4 = mt_rand(0, 9);
    $n5 = mt_rand(0, 9);
    $n6 = mt_rand(0, 9);
    $n7 = mt_rand(0, 9);
    $n8 = mt_rand(0, 9);
    $n9 = 0;
    $n10 = 0;
    $n11 = 0;
    $n12 = 1;
    $d1 = $n12 * 2 + $n11 * 3 + $n10 * 4 + $n9 * 5 + $n8 * 6 + $n7 * 7 + $n6 * 8 + $n5 * 9 + $n4 * 2 + $n3 * 3 + $n2 * 4 + $n1 * 5;
    $d1 = 11 - mod($d1, 11);
    if ($d1 >= 10) {
        $d1 = 0;
    }
    $d2 = $d1 * 2 + $n12 * 3 + $n11 * 4 + $n10 * 5 + $n9 * 6 + $n8 * 7 + $n7 * 8 + $n6 * 9 + $n5 * 2 + $n4 * 3 + $n3 * 4 + $n2 * 5 + $n1 * 6;
    $d2 = 11 - mod($d2, 11);
    if ($d2 >= 10) {
        $d2 = 0;
    }
    $retorno = '';
    if ($compontos) {
        $retorno = '' . $n1 . $n2 . "." . $n3 . $n4 . $n5 . "." . $n6 . $n7 . $n8 . "/" . $n9 . $n10 . $n11 . $n12 . "-" . $d1 . $d2;
    } else {
        $retorno = '' . $n1 . $n2 . $n3 . $n4 . $n5 . $n6 . $n7 . $n8 . $n9 . $n10 . $n11 . $n12 . $d1 . $d2;
    }
    return $retorno;
}
开发者ID:rutkoski,项目名称:simplify-functions,代码行数:35,代码来源:functions.php

示例15: define

define('IN_SITE', 1);
$GLOBALS['root'] = dirname(dirname(__FILE__));
$GLOBALS['local'] = $GLOBALS['root'] . '/local';
$GLOBALS['inc'] = $GLOBALS['root'] . '/inc';
$GLOBALS['templates_path'] = $GLOBALS['local'] . '/templates';
require $GLOBALS['local'] . '/settings.php';
define('TEST', !isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] != 'onlinesequencer.net' || isset($_COOKIE['adminpass']) && $_COOKIE['adminpass'] == $settings['adminpass']);
define('MOBILE_BROWSER', !isset($_GET['desktop']) && (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'Android')));
if (TEST) {
    error_reporting(E_ALL);
} else {
    error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
}
chdir($GLOBALS['root']);
$link = mysqli_connect($settings['mysql_server'], $settings['mysql_user'], $settings['mysql_pass']);
mysqli_select_db($link, $settings['mysql_db']);
function mod($name)
{
    global $inc, $root, $local, $templates_path, $settings, $userid;
    require_once $inc . '/functions.' . $name . '.php';
}
require $GLOBALS['inc'] . "/functions.core.php";
mod("input");
mod("error");
mod("database");
mod('vars');
mod("data");
mod("js");
mod('sequencer');
date_default_timezone_set('America/New_York');
start_buffer();
开发者ID:darwinkim,项目名称:onlinesequencer,代码行数:31,代码来源:init.php


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