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.2.13 / MySQL 5.7 explode trim strpos preg_replace implode file_get_contents
added at:
2024-03-17 01:52:39
1
-
PHP 8.1 / MySQL 5.7 explode trim strpos preg_replace implode file_get_contents
added at:
2024-03-17 01:52:31
2
-
PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace
added at:
2024-03-10 14:48:28
12
-
PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace
added at:
2024-03-10 14:47:51
2
-
PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace mb_strlen
added at:
2024-03-10 14:47:41
1
-
PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace
added at:
2024-03-10 14:05:01
1
-
PHP 8.0 / MySQL 5.7 trim preg_match_all mt_srand mt_rand count strtoupper substr_replace mb_strlen
added at:
2024-03-10 14:04:51
1
-
PHP 8.0 / MySQL 5.7 mb_convert_encoding trim preg_match_all mt_srand mt_rand count substr_replace
added at:
2024-03-10 14:02:24
1
-
PHP 8.0 / MySQL 5.7 trim mt_rand count
added at:
2024-03-09 15:10:13
1
-
PHP 7.4 / MySQL 8.0 fwrite fopen file trim explode str_replace
added at:
2024-03-08 11:37:52
2