PHP sscanf() function is utilized to parse a string according to specific format.
In PHP sscanf() function, the information will be returned as a array, If just two parameters are passed.
In PHP sscanf() function, the information parsed are saved in them., if optional parameters are passed.
Syntax:
sscanf(string,format,arg1,arg2,arg++)
string : Required. Defines the input string being parsed.
format : Required. Defines the format to use
arg1 : Optional. The first variable to store data in
arg2 : Optional. The second variable to store data in
arg++ : Optional. The third, forth, and so on, to store data in
Example:
<?php
$input_str = "Marks : Math – 88 :: Language - 75";
sscanf( $input_str,"Marks : Math - %d :: Language - %d", $math, $language);
var_dump($math, $language);
?>
Output will be:
int 88
int 75
In PHP sscanf() function, the information will be returned as a array, If just two parameters are passed.
In PHP sscanf() function, the information parsed are saved in them., if optional parameters are passed.
Syntax:
sscanf(string,format,arg1,arg2,arg++)
string : Required. Defines the input string being parsed.
format : Required. Defines the format to use
arg1 : Optional. The first variable to store data in
arg2 : Optional. The second variable to store data in
arg++ : Optional. The third, forth, and so on, to store data in
Example:
<?php
$input_str = "Marks : Math – 88 :: Language - 75";
sscanf( $input_str,"Marks : Math - %d :: Language - %d", $math, $language);
var_dump($math, $language);
?>
Output will be:
int 88
int 75
0 comments:
Post a Comment