$text = "\t\tThese are a few words :] ... ";
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
print "\n";
$trimmed = trim[$text];
var_dump[$trimmed];
$trimmed = trim[$text, " \t."];
var_dump[$trimmed];
$trimmed = trim[$hello, "Hdle"];
var_dump[$trimmed];
$trimmed = trim[$hello, 'HdWr'];
var_dump[$trimmed];
// trim the ASCII control characters at the beginning and end of $binary
// [from 0 to 31 inclusive]
$clean = trim[$binary, "\x00..\x1F"];
var_dump[$clean];
________số 8
Note: function return NULL if can't convert argument type.
$text = "\t\tThese are a few words :] ... ";
0
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
$text = "\t\tThese are a few words :] ... ";
1
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
$text = "\t\tThese are a few words :] ... ";
2
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
Nếu tham số $text = "\t\tThese are a few words :] ... ";
3 tùy chọn được chỉ định, thì mảng được trả về sẽ được chia thành các đoạn với mỗi đoạn có chiều dài
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];$text = "\t\tThese are a few words :] ... ";
3, ngoại trừ đoạn cuối cùng có thể ngắn hơn nếu chuỗi không chia đều.
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];$text = "\t\tThese are a few words :] ... ";
3 mặc định là
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];$text = "\t\tThese are a few words :] ... ";
6, nghĩa là mỗi đoạn sẽ có kích thước một byte
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
Lỗi/Ngoại lệ
Nếu $text = "\t\tThese are a few words :] ... ";
3 nhỏ hơn
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];$text = "\t\tThese are a few words :] ... ";
6, một ValueError sẽ được đưa ra
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
Nhật ký thay đổi
Phiên bảnMô tả8. 0. 0Nếu$text = "\t\tThese are a few words :] ... ";
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
3 nhỏ hơn $text = "\t\tThese are a few words :] ... ";
$binary = "\x09Example string\x0A";
$hello = "Hello World";
var_dump[$text, $binary, $hello];
6, một ValueError sẽ được đưa ra ngay bây giờ; ví dụ
Ví dụ #1 Ví dụ sử dụng str_split[]
print "\n";
15
print "\n";
16
print "\n";
17
print "\n";
18
Ví dụ trên sẽ xuất ra
Array [ [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => F [7] => r [8] => i [9] => e [10] => n [11] => d ] Array [ [0] => Hel [1] => lo [2] => Fri [3] => end ]
ghi chú
Ghi chú
str_split[] sẽ chia thành byte, thay vì ký tự khi xử lý chuỗi được mã hóa nhiều byte. Sử dụng mb_str_split[] để chia chuỗi thành các điểm mã
print "\n";
7
print "\n";
8
print "\n";
9
$trimmed = trim[$text];
0
var_dump[$trimmed];
$trimmed = trim[$text];
1
var_dump[$trimmed];
$trimmed = trim[$text];
2
var_dump[$trimmed];
$trimmed = trim[$text];
3
var_dump[$trimmed];
$trimmed = trim[$text];
4
var_dump[$trimmed];
$trimmed = trim[$text];
5
var_dump[$trimmed];
$trimmed = trim[$text];
6
var_dump[$trimmed];
print "\n";
80