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 trim preg_match
last run:
2023-08-22 21:48:27
6
- 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.1 / MariaDB 10 mysqli_query mysqli_fetch_array trim
last run:
2022-12-16 14:12:21
4
- PHP 8.1 / MySQL 5.7 array_map trim array_count_values arsort reset count key
last run:
2022-06-04 05:31:21
4
- PHP 8.0 / MySQL 5.7 var_dump trim
last run:
2021-09-09 12:22:01
4
trim - New snippets
-
PHP 8.1 / MySQL 8.0 strlen substr trim
added at:
2024-09-25 09:12:57
1
-
PHP 8.1 / MySQL 5.7 trim strtolower strlen
added at:
2024-09-15 21:23:46
2
-
PHP 8.1 / MySQL 5.7 trim
added at:
2024-09-15 21:22:53
1
-
PHP 8.1 / MySQL 5.7 trim
added at:
2024-09-15 21:22:41
1
-
PHP 8.1 / MySQL 5.7 trim
added at:
2024-09-15 21:22:31
2
-
PHP 8.1 / MySQL 5.7 htmlspecialchars trim
added at:
2024-09-12 05:38:24
1
-
PHP 8.1 / MySQL 5.7 is_null trim preg_split var_dump count is_numeric print_r preg_match
added at:
2024-09-06 08:41:30
1
-
PHP 8.1 / MySQL 5.7 is_null trim preg_split count is_numeric print_r preg_match
added at:
2024-09-06 08:25:29
1
-
PHP 8.1 / MySQL 8.0 count trim
added at:
2024-08-05 13:04:23
1
-
PHP 8.1 / MySQL 8.0 count trim
added at:
2024-08-05 13:04:14
1