• PHP Video Tutorials

PHP - gmp_import() Function



Definition and Usage

The gmp_import() function imports from a binary string.

Description

The gmp_import() function imports GMP number from the given binary string.

Syntax

gmp_import ( string $data [, int $word_size = 1 [, int $options = GMP_MSW_FIRST | GMP_NATIVE_ENDIAN ]] ) : GMP

Parameters

Sr.No Parameter & Description
1

data

Binary string you want to import.

2

word_size

The default word size is 1.The number of bytes to be shown in each chunk of binary data.It works along with the Options parameter.

3

options

Default value is GMP_MSW_FIRST | GMP_NATIVE_ENDIAN.

Return Values

PHP gmp_import() function returns a GMP number from the binary string.

PHP Version

This function will work from PHP Version greater than 5.6.1.

Example 1

Working of gmp_import −

<?php
   $number = gmp_init(16708);
   $binarystring = gmp_export($number);
	   
   $number = gmp_import($binarystring);
   echo "The gmp number is : ".$number;
?>

This will produce following result −

The gmp number is : 16708

Example 2

Working of gmp_import −

<?php
   $number = gmp_import("\0\1\3\2");
   echo "The gmp number is : ".$number;
?>

This will produce following result −

The gmp number is : 66306
php_function_reference.htm
Advertisements