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 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.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
- PHP 8.0 / MySQL 5.7 var_dump trim
last run:
2021-09-09 12:20:39
4
- PHP 8.0 / MySQL 5.7 preg_match_all reset array_reduce trim array_shift
last run:
2021-11-26 13:24:37
4
trim - New snippets
-
PHP 8.1 / MySQL 5.7 explode array_map implode trim
added at:
2023-09-21 06:28:02
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode trim
added at:
2023-09-21 06:27:45
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode trim
added at:
2023-09-21 06:27:15
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode trim
added at:
2023-09-21 06:27:00
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode trim
added at:
2023-09-21 06:26:50
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode var_dump trim
added at:
2023-09-21 06:26:14
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode var_dump trim
added at:
2023-09-21 06:26:06
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode var_dump trim
added at:
2023-09-21 06:25:54
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode var_dump trim
added at:
2023-09-21 06:25:41
1
-
PHP 8.1 / MySQL 5.7 explode array_map implode var_dump trim
added at:
2023-09-21 06:25:30
1