1--TEST--
2Test rtrim() function : basic functionality
3--FILE--
4<?php
5
6/* Prototype  : string rtrim  ( string $str  [, string $charlist  ] )
7 * Description: Strip whitespace (or other characters) from the end of a string.
8 * Source code: ext/standard/string.c
9*/
10
11echo "*** Testing rtrim() : basic functionality ***\n";
12
13$text  = "---These are a few words---  \t\r\n\0\x0B  ";
14$hello  = "!===Hello World===!";
15$alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
16$binary = "Example string\x0A\x0D";
17
18
19
20echo "\n-- Trim string with all white space characters --\n";
21var_dump(rtrim($text));
22
23echo "\n-- Trim non-whitespace from a string --\n";
24var_dump(rtrim($hello, "=!"));
25
26echo "\n-- Trim some non-white space characters from a string --\n";
27var_dump(rtrim($hello, "!dlWro="));
28
29echo "\n-- Trim some non-white space characters from a string using a character range --\n";
30var_dump(rtrim($alpha, "A..Z"));
31
32echo "\n-- Trim the ASCII control characters at the beginning of a string --\n";
33var_dump(rtrim($binary, "\x00..\x1F"));
34
35?>
36===DONE===
37--EXPECT--
38*** Testing rtrim() : basic functionality ***
39
40-- Trim string with all white space characters --
41string(27) "---These are a few words---"
42
43-- Trim non-whitespace from a string --
44string(15) "!===Hello World"
45
46-- Trim some non-white space characters from a string --
47string(10) "!===Hello "
48
49-- Trim some non-white space characters from a string using a character range --
50string(10) "0123456789"
51
52-- Trim the ASCII control characters at the beginning of a string --
53string(14) "Example string"
54===DONE===