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


PHP number函数代码示例

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


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

示例1: game_status

function game_status($playerid, $gameid)
{
    $query0 = "SELECT * FROM games WHERE gameid = '{$gameid}' ";
    $recordset = mysql_query($query0) or die(mysql_error());
    $row = mysql_fetch_array($recordset);
    //---game stats---//
    $gamecode = $row["gamecode"];
    $boss = $row["boss"];
    $bosshealth = $row["bosshealth"];
    $weather = $row["weather"];
    $story = $row["bossmove"];
    $gamestate = $row["gamestate"];
    $roundcount = $row["roundcount"];
    $arrayplayersid = explode(",", $row["players"]);
    array_pop($arrayplayersid);
    $bossmaxhealth = number("starting_boss_health_per_player") * count($arrayplayersid);
    //---player stats---//
    if ($playerid > 0) {
        $query1 = "SELECT * FROM players WHERE playerid = '{$playerid}' ";
        $recordset = mysql_query($query1) or die(mysql_error());
        $row = mysql_fetch_array($recordset);
        $name = $row["name"];
        $health = $row["health"];
        $strength = $row["strength"];
        $speed = $row["speed"];
        $playermove = $row["playermove"];
        $playerstate = $row["playerstate"];
        $playermaxhealth = number("starting_health");
        $arrayplayerid = array($playerid);
        $arrayplayersid = array_diff($arrayplayersid, $arrayplayerid);
    } else {
        $name = 0;
        $health = 0;
        $strength = 0;
        $speed = 0;
        $playermove = 0;
        $playerstate = 0;
        $playermaxhealth = 0;
    }
    if ($playerstate == "dead") {
        unset($_SESSION["playerid"]);
    }
    //---players list---//
    $arrayplayernames = array("");
    array_pop($arrayplayernames);
    foreach ($arrayplayersid as $playerid) {
        $query2 = "SELECT * FROM players WHERE playerid = '{$playerid}' ";
        $recordset = mysql_query($query2) or die(mysql_error());
        $row = mysql_fetch_array($recordset);
        $arrayplayername = array($row["name"]);
        $arrayplayernames = array_merge($arrayplayernames, $arrayplayername);
    }
    $playernames = "";
    foreach ($arrayplayernames as $playername) {
        $playernames = $playernames . $playername . ",";
    }
    $playernames = substr($playernames, 0, -1);
    return $gameid . ";" . $boss . ";" . $bosshealth . ";" . $weather . ";" . $gamestate . ";" . $roundcount . ";" . $story . ";" . $name . ";" . $health . ";" . $strength . ";" . $speed . ";" . $playermove . ";" . $playerstate . ";" . $playernames . ";" . $bossmaxhealth . ";" . $playermaxhealth . ";" . $gamecode;
    //16
}
开发者ID:maximforever,项目名称:bossfight,代码行数:60,代码来源:status.php

示例2: boss_attack_all

function boss_attack_all($arrayplayersid)
{
    $target = "";
    foreach ($arrayplayersid as $playerid) {
        $target = $target . $playerid . ",";
    }
    $target = substr($target, 0, -1);
    $attack = mt_rand(number("boss_attack_one_min"), number("boss_attack_one_max"));
    return $target . ";" . $attack;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:10,代码来源:bossattackall.php

示例3: log_action

function log_action($user, $action) {
	if (!is_array($user) && strlen(number($user)) < 5)
		if ($u = user($user)) $user = $u;
	if (is_array($user)) $user = $user['phone'];
	redis()->lpush('actions', json_encode(array(
		'phone' => $user,
		'action' => $action,
		'time' => time(),
	)));
}
开发者ID:rishair,项目名称:schlagelink-twilio,代码行数:10,代码来源:Helper.php

示例4: getContractsData

 /**
  * @param int $corporation_id
  *
  * @return mixed
  */
 public function getContractsData(int $corporation_id)
 {
     $contracts = $this->getCorporationContracts($corporation_id, false);
     return Datatables::of($contracts)->editColumn('issuerID', function ($row) {
         return view('web::partials.contractissuer', compact('row'))->render();
     })->editColumn('type', function ($row) {
         return view('web::partials.contracttype', compact('row'))->render();
     })->editColumn('price', function ($row) {
         return number($row->price);
     })->editColumn('reward', function ($row) {
         return number($row->reward);
     })->make('true');
 }
开发者ID:eveseat,项目名称:web,代码行数:18,代码来源:ContractsController.php

示例5: getTransactionsData

 /**
  * @param int $corporation_id
  *
  * @return mixed
  */
 public function getTransactionsData(int $corporation_id)
 {
     $transactions = $this->getCorporationWalletTransactions($corporation_id, false);
     return Datatables::of($transactions)->editColumn('transactionType', function ($row) {
         return view('web::partials.transactiontype', compact('row'))->render();
     })->editColumn('price', function ($row) {
         return number($row->price);
     })->addColumn('total', function ($row) {
         return number($row->price * $row->quantity);
     })->editColumn('clientName', function ($row) {
         return view('web::partials.transactionclient', compact('row'))->render();
     })->make(true);
 }
开发者ID:eveseat,项目名称:web,代码行数:18,代码来源:WalletController.php

示例6: currency

 function currency($amount)
 {
     $position = get('currency.position', 'before');
     $symbol = get('currency.symbol', '$');
     $str = '';
     if ($position === 'before') {
         $str .= $symbol;
     }
     $str .= number($amount);
     if ($position === 'after') {
         $str .= ' ' . $symbol;
     }
     return $str;
 }
开发者ID:cs-team,项目名称:miniflux,代码行数:14,代码来源:Translator.php

示例7: heal

function heal($playerid)
{
    $query1 = "SELECT * FROM players WHERE playerid = '{$playerid}' ";
    $recordset = mysql_query($query1) or die(mysql_error());
    $row = mysql_fetch_array($recordset);
    $gameid = $row["gameid"];
    //---build heal targets---//
    $query2 = "SELECT * FROM games WHERE gameid = '{$gameid}' ";
    $recordset = mysql_query($query2) or die(mysql_error());
    $row = mysql_fetch_array($recordset);
    $arraytargetsid = explode(",", $row["players"]);
    $arrayplayerid = array($playerid);
    $arraytargetsid = array_diff($arraytargetsid, $arrayplayerid);
    $healhealth = mt_rand(number("heal_health_min"), number("heal_health_max"));
    $healstrength = mt_rand(number("heal_strength_min"), number("heal_strength_max"));
    $healspeed = mt_rand(number("heal_speed_min"), number("heal_speed_max"));
    //---heal targets---//
    foreach ($arraytargetsid as $targetid) {
        $query3 = "SELECT * FROM players WHERE playerid = '{$targetid}' ";
        $recordset = mysql_query($query3) or die(mysql_error());
        $row = mysql_fetch_array($recordset);
        $health = $row["health"];
        $strength = $row["strength"];
        $speed = $row["speed"];
        if ($health > 0) {
            $newhealth = $health + $healhealth;
            $newstrength = $strength + $healstrength;
            $newspeed = $speed + $healspeed;
            if ($newhealth > number("starting_health")) {
                $newhealth = number("starting_health");
            }
            if ($newstrength > number("starting_strength")) {
                $newstrength = number("starting_strength");
            }
            if ($newspeed > number("starting_speed")) {
                $newspeed = number("starting_speed");
            }
            //---update stats---//
            $query2 = "UPDATE players SET health = ('{$newhealth}') WHERE playerid = '{$targetid}' ";
            mysql_query($query2) or die(mysql_error());
            $query3 = "UPDATE players SET strength = ('{$newstrength}') WHERE playerid = '{$targetid}' ";
            mysql_query($query3) or die(mysql_error());
            $query4 = "UPDATE players SET speed = ('{$newspeed}') WHERE playerid = '{$targetid}' ";
            mysql_query($query4) or die(mysql_error());
        }
    }
}
开发者ID:maximforever,项目名称:bossfight,代码行数:47,代码来源:heal.php

示例8: get_wait_info

function get_wait_info($data)
{
    require_once 'common_natural_language.php';
    global $mysqli;
    $fork_key = $data['fork_key'];
    $sql = sprintf("select `Fork Key`,`Fork Result`,`Fork Scheduled Date`,`Fork Start Date`,`Fork State`,`Fork Type`,`Fork Operations Done`,`Fork Operations No Changed`,`Fork Operations Errors`,`Fork Operations Total Operations` from `Fork Dimension` where `Fork Key`=%d ", $fork_key);
    $res = $mysqli->query($sql);
    if ($row = $res->fetch_assoc()) {
        $result_extra_data = array();
        switch ($data['tag']) {
            case 'journals':
                $formated_tag = ' ' . ngettext('journal', 'journals', $row['Fork Operations Total Operations']);
                break;
            default:
                $formated_tag = ' ' . ngettext('record', 'records', $row['Fork Operations Total Operations']);
        }
        $etr = '';
        if ($row['Fork State'] == 'In Process') {
            //$msg=number($row['Fork Operations Done']+$row['Fork Operations Errors']+$row['Fork Operations No Changed']).'/'.$row['Fork Operations Total Operations'];
            $formated_status = _('In Process');
            $formated_progress = _('Processing') . ' ' . number($row['Fork Operations Done']) . ' ' . _('of') . ' ' . number($row['Fork Operations Total Operations']);
            $formated_progress .= $formated_tag;
            if ($row['Fork Operations Done'] > 1) {
                $etr = _('ETA') . ': ' . seconds_to_string(($row['Fork Operations Total Operations'] - $row['Fork Operations Done']) * (gmdate('U') - strtotime($row['Fork Start Date'])) / $row['Fork Operations Done']);
            }
        } elseif ($row['Fork State'] == 'Queued') {
            $formated_status = _('Queued');
            $formated_progress = _('Records to process') . ': ' . number($row['Fork Operations Total Operations']);
        } elseif ($row['Fork State'] == 'Finished') {
            $formated_status = _('Finished');
            $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed');
        } elseif ($row['Fork State'] == 'Cancelled') {
            $formated_status = _('Cancelled');
            $formated_progress = number($row['Fork Operations Done']) . $formated_tag . ' ' . _('processed');
        } else {
            $formated_status = $row['Fork State'];
            $formated_progress = '';
        }
        $response = array('state' => 200, 'date' => gmdate('Y-m-d H:i:s'), 'fork_key' => $fork_key, 'fork_state' => $row['Fork State'], 'done' => number($row['Fork Operations Done']), 'no_changed' => number($row['Fork Operations No Changed']), 'errors' => number($row['Fork Operations Errors']), 'total' => number($row['Fork Operations Total Operations']), 'todo' => number($row['Fork Operations Total Operations'] - $row['Fork Operations Done']), 'result' => $row['Fork Result'], 'formated_status' => $formated_status, 'formated_progress' => $formated_progress . '<br>' . $etr, 'progress' => sprintf('%s/%s (%s)', number($row['Fork Operations Done']), number($row['Fork Operations Total Operations']), percentage($row['Fork Operations Done'], $row['Fork Operations Total Operations'])), 'tag' => $data['tag'], 'result_extra_data' => $result_extra_data, 'etr' => $etr);
        echo json_encode($response);
    } else {
        $response = array('state' => 400);
        echo json_encode($response);
    }
}
开发者ID:inikoo,项目名称:fact,代码行数:45,代码来源:ar_fork.php

示例9: new_player

function new_player($name, $gameid, $browserinfo)
{
    $randomseed = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(1, 16))), 0, 16);
    $starting_health = number("starting_health");
    $starting_strength = number("starting_strength");
    $starting_speed = number("starting_speed");
    $query1 = "INSERT INTO players (name, gameid, health, strength, speed, playerstate, browserinfo) VALUES ('{$name}','{$gameid}','{$starting_health}','{$starting_speed}','{$starting_strength}','{$randomseed}','{$browserinfo}')";
    mysql_query($query1) or die(mysql_error());
    $query2 = "SELECT * FROM players WHERE name = '{$name}' AND playerstate = '{$randomseed}' ";
    $recordset = mysql_query($query2) or die(mysql_error());
    $row = mysql_fetch_array($recordset);
    $playerid = $row["playerid"];
    $query3 = "UPDATE players SET playerstate = ('setting up') WHERE playerid = '{$playerid}' AND playerstate = '{$randomseed}' ";
    mysql_query($query3) or die(mysql_error());
    $query4 = "UPDATE games SET players = CONCAT(players,'{$playerid},') WHERE gameid = '{$gameid}' ";
    mysql_query($query4) or die(mysql_error());
    return $playerid;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:18,代码来源:newplayer.php

示例10: getMarketData

 /**
  * @param int $character_id
  *
  * @return mixed
  */
 public function getMarketData(int $character_id)
 {
     $orders = $this->getCharacterMarketOrders($character_id, false);
     $states = $this->getEveMarketOrderStates();
     return Datatables::of($orders)->addColumn('bs', function ($row) {
         return view('web::partials.marketbuysell', compact('row'))->render();
     })->addColumn('vol', function ($row) {
         return view('web::partials.marketvolume', compact('row'))->render();
     })->addColumn('state', function ($row) use($states) {
         return $states[$row->orderState];
     })->editColumn('price', function ($row) {
         return number($row->price);
     })->addColumn('total', function ($row) {
         return number($row->price * $row->volEntered);
     })->editColumn('typeName', function ($row) {
         return view('web::partials.markettype', compact('row'))->render();
     })->make(true);
 }
开发者ID:eveseat,项目名称:web,代码行数:23,代码来源:MarketController.php

示例11: boss_move

function boss_move($gameid)
{
    $query1 = "SELECT * FROM games WHERE gameid = '{$gameid}' ";
    $recordset = mysql_query($query1) or die(mysql_error());
    $row = mysql_fetch_array($recordset);
    $players = $row["players"];
    $arrayplayersid = explode(",", $players);
    array_pop($arrayplayersid);
    $randomnumber = mt_rand(0, 99);
    //---defend---//
    if ($randomnumber < number("percentage_boss_dodge")) {
        $move = "dodge";
    } elseif ($randomnumber > number("percentage_boss_dodge") - 1 and $randomnumber < number("percentage_boss_dodge") + number("percentage_boss_attack_all")) {
        $move = "attackall";
    } elseif ($randomnumber > 99 - number("percentage_boss_attack_one")) {
        $move = "attackone";
    }
    return $move;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:19,代码来源:bossmove.php

示例12: change_weather

function change_weather($weather)
{
    $randomchange = mt_rand(0, 99);
    if ($randomchange > number("percentage_weather_change")) {
        $newweather = $weather;
    } else {
        $randomweather = mt_rand(0, 99);
        if ($randomweather < number("percentage_weather_sunny")) {
            $newweather = "sunny";
        } elseif ($randomweather > number("percentage_weather_sunny") - 1 and $randomweather < number("percentage_weather_sunny") + number("percentage_weather_windy")) {
            $newweather = "windy";
        } elseif ($randomweather > number("percentage_weather_sunny") + number("percentage_weather_windy") - 1 and $randomweather < number("percentage_weather_sunny") + number("percentage_weather_windy") + number("percentage_weather_rainy")) {
            $newweather = "rainy";
        } elseif ($randomweather > 99 - number("percentage_weather_snowy")) {
            $newweather = "snowy";
        }
    }
    return $newweather;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:19,代码来源:changeweather.php

示例13: struk

function struk($pembelian, $bayar, $voucher = 0, $output = null)
{
    $recipe = new RecipeMaker(40);
    $recipe->center('NIMCO STORE')->breaks();
    $recipe->center('Jl. Cendrawasih No. 25')->breaks();
    $recipe->center('Demangan Baru Yogyakarta')->breaks();
    $recipe->center('Telp : ( 0274 ) 549827')->breaks();
    $recipe->breaks(' ');
    $recipe->left('TRNS-00001')->right('Nama Kasir')->breaks();
    $recipe->left(date('d-m-Y'))->right('Nama Member')->breaks();
    $recipe->breaks('-');
    $jual = 0;
    $total_diskon = 0;
    $grand_total = 0;
    foreach ($pembelian as $key => $value) {
        $value['sub_total'] = $value['harga'] * $value['qty'];
        $jual += $value['sub_total'];
        $recipe->left($value['kode'] . ' (' . $value['qty'] . ' x ' . number($value['harga']) . ')')->right(number($value['sub_total']))->sparator()->breaks();
        if ($value['diskon']) {
            $diskon = $value['diskon'] * $value['sub_total'] / 100;
            $recipe->left('- Diskon (' . $value['diskon'] . '%)')->right(number($diskon))->sparator()->breaks();
            $total_diskon += $diskon;
        }
    }
    $grand_total = $jual - ($total_diskon + $voucher);
    $kembali = $bayar - $grand_total;
    $recipe->breaks('-');
    $recipe->left('Harga Jual')->right(number($jual))->sparator()->breaks();
    $recipe->left('Total Diskon')->right(number($total_diskon))->sparator()->breaks();
    $recipe->left('Voucher')->right(number($voucher))->sparator()->breaks();
    $recipe->left('Grand Total')->right(number($grand_total))->sparator()->breaks();
    $recipe->left('Bayar')->right(number($bayar))->sparator()->breaks();
    $recipe->left('Kembali')->right(number($kembali))->sparator()->breaks();
    $recipe->breaks(' ');
    $recipe->center('Terima Kasih & Selamat Belanja Kembali')->breaks();
    $recipe->end();
    if ($output == 'HTML') {
        return $recipe->outputHTML();
    } else {
        return $recipe->output();
    }
}
开发者ID:agungjk,项目名称:POS-Recipe-maker,代码行数:42,代码来源:test.php

示例14: boss_attack_one

function boss_attack_one($arrayplayersid)
{
    $arraytargets = array("");
    array_pop($arraytargets);
    foreach ($arrayplayersid as $playerid) {
        $query2 = "SELECT * FROM players WHERE playerid = '{$playerid}' ";
        $recordset = mysql_query($query2) or die(mysql_error());
        $row = mysql_fetch_array($recordset);
        $health = $row["health"];
        $arrayplayerid = array($playerid);
        $x = 0;
        while ($x < $health) {
            $arraytargets = array_merge($arraytargets, $arrayplayerid);
            $x = $x + 1;
        }
    }
    shuffle($arraytargets);
    $target = $arraytargets[0];
    $attack = mt_rand(number("boss_attack_one_min"), number("boss_attack_one_max"));
    return $target . ";" . $attack;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:21,代码来源:bossattackone.php

示例15: start_game

function start_game($gameid)
{
    $query1 = "UPDATE games SET gamestate=('playerturn') WHERE gameid = '{$gameid}' ";
    mysql_query($query1) or die(mysql_error());
    $query2 = "SELECT * FROM players WHERE gameid =('{$gameid}') ";
    $recordset = mysql_query($query2) or die(mysql_error());
    $arrayplayersid = array("");
    array_pop($arrayplayersid);
    while ($row = mysql_fetch_array($recordset)) {
        $playerid = $row["playerid"];
        $arrayplayerid = array($playerid);
        $arrayplayersid = array_merge($arrayplayersid, $arrayplayerid);
    }
    $bosshealth = 0;
    foreach ($arrayplayersid as $playerid) {
        $query3 = "UPDATE players SET playerstate =('playerturn') WHERE playerid = '{$playerid}' ";
        mysql_query($query3) or die(mysql_error());
        $bosshealth = $bosshealth + number("starting_boss_health_per_player");
    }
    $query4 = "UPDATE games SET bosshealth = ('{$bosshealth}') WHERE gameid = '{$gameid}' ";
    mysql_query($query4) or die(mysql_error());
    return $gameid;
}
开发者ID:maximforever,项目名称:bossfight,代码行数:23,代码来源:startgame.php


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