trim
trim — Strip whitespace (or other characters) from the beginning and end of a string.Description
trim( string $string, string $characters = " \n\r\t\v\0" ): stringThis function returns a string with whitespace stripped from the beginning and end of string. Without the second parameter, trim() will strip these characters:
• " " (ASCII 32 (0x20)), an ordinary space.
• "\t" (ASCII 9 (0x09)), a tab.
• "\n" (ASCII 10 (0x0A)), a new line (line feed).
• "\r" (ASCII 13 (0x0D)), a carriage return.
• "\0" (ASCII 0 (0x00)), the NUL-byte.
• "\v" (ASCII 11 (0x0B)), a vertical tab.
Parameters
string
The string that will be trimmed.
characters
Optionally, the stripped characters can also be specified using the characters parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.
Return Values
The trimmed string.More information about trim on official PHP documentation site
trim - Popular snippets
- PHP 7.4 / MySQL 8.0 mysqli_query mysqli_fetch_assoc explode count array_push trim array_count_values array_keys print_r
last run:
2023-06-06 16:46:02
15
- PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace
last run:
2024-03-10 14:50:03
12
- PHP 7.4 / MySQL 8.0 mysqli_query mysqli_fetch_assoc explode count array_push trim print_r array_count_values
last run:
2022-06-20 17:40:11
8
- PHP 8.0 / MySQL 5.7 array_reduce explode trim array_push print_r
last run:
2022-09-08 15:37:19
7
- PHP 8.1 / MySQL 8.0 array_fill microtime trim
last run:
2024-10-09 08:25:44
6
- PHP 8.1 / MySQL 8.0 trim preg_match
last run:
2023-08-22 21:48:27
6
- PHP 8.0 / MySQL 8.0 array_fill microtime implode trim array_merge
last run:
2024-10-09 08:29:18
5
- PHP 8.1 / MySQL 5.7 explode trim
last run:
2024-01-30 03:19:36
5
- PHP 8.0 / MySQL 5.7 explode trim
last run:
2021-10-07 05:04:14
5
- PHP 8.0 / MySQL 8.0 array_fill microtime implode trim array_merge
last run:
2024-10-09 07:26:45
4
trim - New snippets
-
PHP 8.1 / MySQL 8.0 strlen substr trim
added at:
2024-11-18 12:26:53
1
-
PHP 8.1 / MySQL 5.7 trim explode count
added at:
2024-11-15 08:09:05
1
-
PHP 8.1 / MySQL 5.7 trim
added at:
2024-11-15 08:08:10
1
-
PHP 8.1 / MySQL 5.7 trim
added at:
2024-11-15 08:07:57
1
-
PHP 8.1 / MySQL 5.7 trim htmlspecialchars number_format
added at:
2024-11-15 08:07:35
1
-
PHP 8.1 / MySQL 5.7 trim intval floatval
added at:
2024-11-15 08:06:13
1
-
PHP 8.1 / MySQL 5.7 trim fgets strtoupper round trim fgets strtoupper round
added at:
2024-10-27 08:59:35
1
-
PHP 8.1 / MySQL 5.7 trim is_numeric
added at:
2024-10-22 15:51:01
1
-
PHP 8.1 / MySQL 5.7 trim is_numeric
added at:
2024-10-22 15:50:29
2