String Functions in PHP: Part 13

Introduction

In this article I describe the PHP string functions quotemeta, rtrim and setlocal. 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
     
  10. String Functions in PHP:Part10
     
  11. String Functions in PHP:Part11
     
  12. String Functions in PHP:Part12

PHP quotemeta() Function

The PHP string quotemeta() function returns the string with meta characters quoted or say it adds backslashes in front of some predefined characters in a string.

Syntax

quotemeta(string)

Parameter in quotemeta Function

The parameters of the quotemeta function is:

Parameter Description
strings It specifies the string to check.

Example

An example of the
quotemeta function is:

<?php

$str = "Mcn Solution. (PVT LTD)";

echo quotemeta($str);

?>

Output

quotemeta-string-function-in-php.gif

PHP rtrim() Function

The PHP rtrim function will remove whitespace or other characters from the end of the string.

Syntax

rtrim(string,charlist)

Parameter in rtrim Function

The parameters of the rtrim  function are:

Parameter Description
string It specifies the string to check.
arg1 It specifies which characters to remove from the string.

Example

An example of the rtrim
function is:

<?php

$str = "MCN Solution!    ";

echo "Without rtrim: " . $str;

echo "<br />";

echo "With rtrim: " . rtrim($str);

?>

Output

rtrim-string-function-in-php.gif

View Source Code

rtrim-string-function-source-code.gif

PHP setlocal() Function

The PHP setlocal function is used to set local information.

Syntax

setlocal(constant, location)

Parameter in setlocal Function

The parameters of the setlocal  function are:

Parameter Description
constant It specifies what local information should be set.
location It specifies what country or region to set the locale information to. Can be a string or an array.

Example

An example of the setlocal
function is:

<?php

echo setlocale(LC_ALL,NULL);

?>

Output

set-local-string-function-in-php.gif