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 5.7 trim fgets
added at:
2024-12-20 14:52:44
1
-
PHP 8.1 / MySQL 5.7 http_response_code json_encode printf htmlspecialchars trim
added at:
2024-12-10 08:08:14
1
-
PHP 8.1 / MySQL 5.7 explode mb_internal_encoding mb_strtoupper mb_substr trim implode
added at:
2024-12-06 18:05:20
1
-
PHP 8.1 / MySQL 5.7 session_start trim mysqli_real_escape_string floatval
added at:
2024-12-05 16:06:16
1
-
PHP 8.1 / MySQL 5.7 session_start trim mysqli_real_escape_string floatval
added at:
2024-12-05 16:05:45
1
-
PHP 8.1 / MySQL 5.7 session_start trim mysqli_real_escape_string floatval
added at:
2024-12-05 16:05:21
1
-
PHP 8.1 / MySQL 5.7 session_start trim mysqli_real_escape_string floatval
added at:
2024-12-05 16:04:35
3
-
PHP 8.1 / MySQL 5.7 session_start trim mysqli_real_escape_string floatval
added at:
2024-12-05 16:04:11
1
-
PHP 8.2.13 / MariaDB 11.4 is_array array_keys htmlspecialchars trim
added at:
2024-12-03 10:47:35
1
-
PHP 8.1 / MySQL 8.0 strlen substr trim
added at:
2024-11-25 16:01:40
1