Home > Backend Development > PHP Tutorial > vsprintf() function in PHP

vsprintf() function in PHP

王林
Release: 2023-08-28 09:46:01
forward
1413 people have browsed it

vsprintf() function in PHP

vsprint() function returns a formatted string.

Syntax

vsprintf(format,argarray)
Copy after login

Parameters

  • Format - Specifies the string and how to format the variables within it.

  • The following are possible format values ​​-

    • %% - Returns the percent sign

    • %b - Binary number

    • %c - Convert the character to an ASCII value

    • %d - Signed decimal number (negative, zero, or positive)

    • < p>%e - Use Scientific notation with lowercase letters (e.g. 1.2e 2)

    • %E - Scientific notation with uppercase letters (e.g. 1.2E 2)

    • %u - Unsigned decimal number (equal to or greater than zero)

      < /li>
    • %f - Float Points (local settings aware)

    • %F > - Floating point (local settings not supported)

    • %g - The shorter of %e and %f

    • %G - The shorter of %E and %f

    • %o - Octal number

    • ##%s - String

    • %x - Hexadecimal number (lowercase letters)

    • %X - Hexadecimal number (capital letters)

  • arg - an array containing the arguments to insert the % symbol into the format string

Return

The vsprintf() function returns a value in the form of a formatted string.

Example

The following is an example -

Real-time demonstration

<?php
$a = 6567;
$b = 8976;
$res = vsprintf("%f</p><p>%f",array($a,$b));
echo $res;
?>
Copy after login

Output

6567.000000
8976.000000
Copy after login

The above is the detailed content of vsprintf() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template