Change language

PHP pack () function

Syntax:
pack ($format, $arguments)
Parameters:this function takes two parameters as specified above and described below:
  • $format:required. It defines the format to be used when packing data. Possible format values:
    • a- NUL-padded string
    • A- line with space
    • h- low hex first hex line
    • H- high hex first hex line
    • c- signed character
    • C- unsigned character
    • s- short signature (16 bit, machine byte order)
    • S- unsigned short (16 bit, machine byte order)
    • n- unsigned short (16 bit, big endian byte order)
    • v- unsigned short (16 bit, big endian byte order)
    • i- signed integer (machine dependent byte order and size)
    • I- unsigned integer (machine dependent byte order and size)
    • l- long signature (32 bits, machine byte order)
    • L- unsigned long (32 bit, machine byte order)
    • N- unsigned long (32 bit, big endian byte order)
    • V- unsigned long (32-bit, big endian byte order)
    • f- float (machine dependent representation and size)
    • d- double (machine-dependent representation and size)
    • x- NUL bytes
    • X- Back up one byte
    • Z- NUL-padded string
    • @- NUL-fill to absolute position
  • $arguments:This is an optional parameter. It specifies one or more arguments to pack.
Return Value:Returns a binary string containing data.Note. This function is available in PHP 4.0.0 and later.Program 1:This program uses the Cformat to format the input parameter. echo pack ( "C13" , 71, 69, 69, 75, 83, 70, 79, 82, 71, 69, 69, 75, 83); ?> Exit:
GEEKSFORGEEKS  Program 2:This program uses the Aformat to format the input parameter.       echo  pack (  "A3" , 71898); ?>  Exit:
718  Program 3:This program uses the iformat to format the input parameter.       echo  pack (  "i3" , 56, 49, 54); ?>  Exit:
816  Link: https://www. php.net/manual/en/function.pack.php  
    

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method