PHP sscanf Function
What is sscanf Function?
Explanation
In PHP, this function parses input from a string according to a format.
Syntax:
sscanf(string,format,arg1,arg2,arg++)
In the above syntax sscanf Function reads from the "string" and interprets it according to the specified "format" , which is described in the documentation for sprintf().) " %% ,%b , %c, %d, %e, %u, %f, %F, %o, %s, %x, %X ", "arg1" is the first variable to store data, "arg2" is the second variable to store data, "arg++" is the variable to store third, fourth variables.
Example :
<?php
$string = "age:50 weight:60kg";
sscanf($string,"age:%d weight:%dkg",$age,$weight);
// show types and values
var_dump($age,$weight);
?>
Result :
int(50)
int(60)
In the above sscanf Function example the string is parsed according to the specified format "%d" which specifies the integer.