• PHP Video Tutorials

PHP - gmp_scan0() Function



Definition and Usage

The gmp_scan0() function scans the 0's in the given number.

Description

The gmp_scan0() scans the GMP number from the given start position for 0.It will stop when it gets the first non-zero value.

Syntax

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

Parameters

Sr.No Parameter & Description
1

a

GMP number that will be scanned.

2

start

The starting position from where the scan will begin.

Return Values

PHP gmp_scan0() function returns an integer value for the the position or index of the bit found. The index starts from 0..

PHP Version

This function will work from PHP Version greater than 5.0.0.

Example 1

Working of gmp_scan0() −

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

This will produce following result −

The position of 0 is :2

Example 2

Working of gmp_scan0() −

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

This will produce following result −

The position of 0 is :4
php_function_reference.htm
Advertisements