How to use sscanf in PHP
In this article I will explain how the sscanf() function can be used in PHP.
sscanf() function in PHP
- The sscanf() function is used to parse input from a string according to a specified format string.
- In sscanf() function, the data will be returned as an array, If only two parameters are passed.
- In sscanf() function, the data parsed are stored in them., if optional parameters are passed.
Syntax
sscanf(string,format,arg1,arg2,arg++) |
Parameter
Example
The following example show to how the sscanf() function can be used in PHP.
<html>
<body>
<h3 style="color: grey;">sscanf() function example in PHP</h3>
<?php
$input_value = 'Marks : English - 90 :: Hindi - 85';
sscanf($input_value, 'Marks : English - %d :: Hindi - %d', $English, $Hindi);
var_dump($English, $Hindi);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here