| Previous | Home | Next |
sprintf()
The sprintf() function writes a formatted string to a variable.
Syntax:sprintf(format,arg1,arg2,arg++)
Example:
<?php
$number = 9;
$str = sprintf("%d is a number.",$number);
echo $str;
?>
Output:
sscanf()
The sscanf() function parses input from a string according to a specified format. The sscanf() function parses a string into variables based on the format string.
Syntax:sscanf(string,format,arg1,arg2,arg++)
Example:
<?php $str = "age:25 class:1"; sscanf($str,"age:%d class:%d",$age,$class); // show types and values var_dump($age,$class); ?>
Output:
| Previous | Home | Next |