String Functions in PHP: Part 10

Introduction

In this article I describe the PHP string functions money_format, ln_langinfo and
nl2br. To learn some other math functions, go to:

  1. String Functions in PHP: Part1
     
  2. String Functions in PHP:Part2
     
  3. String Functions in PHP:Part3
     
  4. String Functions in PHP:Part4
     
  5. String Functions in PHP:Part5
     
  6. String Functions in PHP:Part6
     
  7. String Functions in PHP:Part7
     
  8. String Functions in PHP:Part8
     
  9. 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:

money-format-string-function-in-php.jpg

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

nl_langinfo(element)

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

nl2br(string)

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:

nl2br-string-function-in-php.jpg


Similar Articles