PHP - trim
Trieda
Metóda - trim
(PHP 4, PHP 5, PHP 7)
The trim() function removes all so-called white spaces at the
beginning and the end of a string. White spaces include spaces, tabs, ends of
lines and other characters. These characters are:
" ", "\t",
"\n", "\r",
"\0", "\x0B".
If we want to remove white spaces only from one side of the string, we use
ltrim() and rtrim() functions (from the left and from
the right).
Procedurálne
- function trim (string $str, string $character_mask = \t\n\r\0\x0B) : string
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $str | string | The string to convert. | |
| $character_mask | string | \t\n\r\0\x0B | The enumeration of characters (in one string) to remove. They are removed only from the beginning and end of a string! |
Mávratovej hodnoty
Vracia: string
The string without white characters.
Príklady
<?php
$s = " name \n\t ";
$s = trim($s);
var_dump($s);
Súvisiace manuály
- function str_replace (mixed $search, mixed $replace, mixed $subject, int &$count) : mixed
