Introduction
In this article I describe the PHP string functions number_format, ord and parse_str. To learn some other math functions, go to:
- String Functions in PHP: Part1
- String Functions in PHP:Part2
- String Functions in PHP:Part3
- String Functions in PHP:Part4
- String Functions in PHP:Part5
- String Functions in PHP:Part6
- String Functions in PHP:Part7
- String Functions in PHP:Part8
- String Functions in PHP:Part9
- String Functions in PHP:Part10
PHP number_format() Function
The PHP number_format function is used to set the format of numeric output.
Syntax
| number_format (number,decimals,decimalpoint, separator) |
Parameter in number_format Function
The parameters of the money_format function are:
| Parameter | Description |
| number | It specifies the number to be formatted. |
| decimals | It sets the number of decimal points. |
| decimalpoint | It specifies what string is used for the decimal point. |
| separator | It sets the thousands separator. |
Example
An example of the number_format function is:
<?php
echo number_format("999999");
echo "<br />";
echo number_format("999999",2);
echo "<br />";
echo number_format("1000000",2,",",".");
?>
Output
PHP ord() Function
The PHP ord function returns the ASCII value of the first character of a string.
Syntax
| ord(string) |
Parameter in ord Function
The parameter of the ord function is:
| Parameter | Description |
| string | It specifies a string to get the ASCII value from |
Example
An example of the money_format function is:
<?php
echo ord("M")."</br>";
echo ord("MCN");
?>
Output
PHP parse_str() Function
The PHP parse_str function parses the string into a variable.
Syntax
| parse_str(string,array) |
Parameter in parse_str Function
The parameters of the parse_str function are:
| Parameter | Description |
| string | It specifies input string. |
| array | It specifies the name of the array to store the variable. |
Example
An example of the parse_str function is:
<?php
parse_str("Rank=1&compname=Mcn%20Solution",$ArrayVal);
echo "<pre>";
print_r($ArrayVal);
?>
Output

Join the conversation! Your thoughts help the community grow.