Introduction
In this article I describe the PHP string functions money_format, ln_langinfo and nl2br. 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
PHP money_format() Function
The PHP money_format function formats a number as a currency string.
Syntax
money_format (string,number) |
Parameters in the money_format Function
The parameters of the money_format function are:
Parameter |
Description |
string |
It specifies the string to be formatted. |
number |
It specifies the number to be formatted. |
Example
An example of the money_format function is:
<?php
$number = 123467.89;
echo "$ ".number_format($number, 2);
?>
Output:
PHP ln_langnfo() Function
The PHP ln_langinfo function returns specific local information. The function returns specific information on access or false on failure.
Syntax
Parameter in ln_langnfo Function
The parameters of the ln_langinfo function are:
Parameter |
Description |
element |
It specifies which element to return. |
PHP nl2br() Function
The PHP nl2br function inserts HTML line breaks before all newlines in a string.
Syntax
Parameter in nl2br Function
The parameters of the nl2br function are:
Parameter |
Description |
string |
It specifies the string to check. |
Example
An example of the nl2br function is:
<?php
$str="One Line \n Second Line";
echo "Simple:". $str."</br>";
echo "When using nl2br:.<br>";
echo nl2br($str);
?>
Output: