PHP - gmp_scan0() 函式



定義和用法

gmp_scan0() 函式掃描給定數字中的 0。

描述

gmp_scan0() 從給定的起始位置掃描 GMP 數字中的 0。當它得到第一個非零值時將停止。

語法

gmp_scan0 ( GMP $a , int $start ) : int

引數

序號 引數及描述
1

a

將要掃描的 GMP 數字。

2

start

掃描將開始的起始位置。

返回值

PHP gmp_scan0() 函式返回找到的位的索引(位置)的整數值。索引從 0 開始。

PHP 版本

此函式適用於 PHP 5.0.0 及更高版本。

示例 1

gmp_scan0() 的工作原理 -

<?php
   $num = gmp_init("10111011", 2);
   $pos = gmp_scan0($num, 0);
   echo "The position of 0 is :".$pos;
?>

這將產生以下結果 -

The position of 0 is :2

示例 2

gmp_scan0() 的工作原理 -

<?php
   $num = gmp_init("101110000111", 2);
   $pos = gmp_scan0($num, 4);
   echo "The position of 0 is :".$pos;
?>

這將產生以下結果 -

The position of 0 is :4
php_function_reference.htm
廣告