Substr là gì

Chức năng substr() có thể trả lại dù undef,

hay một chuỗi.

Function substr() may return either undef, or a string.

Đây là một ví dụ sử dụng substr() để thay thế:.

Here is an example using substr() to replace:.

Khi sử dụng substr() với hai hoặc ba tranh luận,

các ban đầu chuỗi giá trị không thay đổi.

When using substr() with two or three arguments,

the original string value does not change.

Khi sử dụng substr() với bốn lập luận thay đổi giá trị của một biến.

When using substr() with four arguments changes the value of a variable.

Chức năng substr(), bạn phải xác định hai,

ba, hoặc bốn, lập luận.

Function substr(), you must specify two, three, or four arguments.

Nếu mô tả bộ biến thế có' substr' lưu lượng truy cập

bộ chuyển đổi này được bỏ qua( chế độ passthrough).

If the adapter description contains'substr' traffic for this adapter is ignored(passthrough mode).

Trong trường hợp nếu anh cố gắng sử dụng các chức năng substr() không có lý luận, hoặc với ai tranh luận, nó sẽ lỗi:.

In the case if you try to use the function substr() with no arguments, or with one argument, it will error:.

Chức năng substr() bạn đến xác định giá trị cho các số thứ hai. Chương

trình ví dụ:.

Function substr() allows you to specify negative values for the second argument.

Example program:.

Nếu start là số âm và abs(

start) lớn hơn chiều dài của chuỗi, substr() coi 0 như là chỉ số bắt đầu.

If start is negative and abs(start)

is larger than the length of the string, substr uses 0 as the start index.

Chúng có thể được cắt theo một độ dài cụ thể bằng cách sử dụng hàm substr().

These can be trimmed to a specific length using the substr() function.

Nếu start là số dương và lớn hơn hoặc

bằng chiều dài của chuỗi, substr() trả về một chuỗi rỗng.

If start is positive and greater than, or equal,

to the length of the string, substr() returns an empty string.

Entry substr($str, -3) is quite similar substr($str, -3, 3).

Substr() bắt đầu lấy các ký

tự tại start và thu thập length các ký tự( trừ khi nó chấm tới cuối chuỗi trước, trong trường hợp này nó sẽ trả về ít hơn).

Substr begins extracting characters at start

and collects length characters(unless it reaches the end of the string first, in which case it will return fewer).

Khi sử dụng hai lập luận substr($ str,$ offset) các chức năng trở về tất cả các nhân vật

từ những chuỗi$ str bắt đầu với các nhân vật ở vị trí$ offset đến cuối hàng.

When using two arguments substr($str,$offset) the function returns all characters from the string$str

starting with the character at position$offset to the end of the row.

Chức năng gọi substr($ str,

7, 5) nói bạn cần để có được từ dòng$ str năm nhân vật, bắt đầu từ vị trí thứ bảy.

Call function substr($str, 7,

5) says you need to get from line$str five characters, starting from the seventh position.

Khi sử dụng ba lập luận substr($ str,$ offset,$ length)

các chức năng trở về$ length vật từ một chuỗi$ str bắt đầu với các nhân vật ở vị trí$ offset.

When using three arguments substr($str,$offset,$length) the function returns$length characters

from a string$str starting with the character at position$offset.

Đệ quy được hiểu là một hàm tự gọi lại chính nó,

trong bài toán này mình sẽ sử dụng substr() method để cắt dần chuỗi

và sử dụng access string syntax để thêm kí tự vừa cắt ra vào cuỗi chuỗi.

Recursive is understood as a function that calls itself,

in this problem I will use the substr() method to cut the string gradually

and use access string syntax to add the cut-out character to the last string.

Nếu bạn sử dụng bốn lập luận substr($ str,$ offset,$ replacement)

chức năng trở lại giống như trong trường hợp của ba lập luận, nhưng ngoài ra thay thế trong các ban đầu chuỗi các giá trị thu được bằng$ replacement.

If you use four arguments substr($str,$offset,$replacement)function returns the same as

in the case of three arguments, but additionally replace in the original string, the value obtained by$replacement.

Đó là lý do tại sao tôi phụ thêm vào chuỗi này" 000000000"( một chuỗi với

chín số không) và sau đó cắt nó với substr() chức năng để làm cho

nó chín ký tự chính xác( điền số 0 ở bên phải).

That's why i'm appending to this string"0000000000"(a string with nine zeros)

and then cutting it off with substr() function to make it nine characters exactly(filling zeros to the right).

Trở lại giá trị khi bạn gọi substr($ str, 7, 5,' you') chính xác là giống như khi bạn gọi substr($ str, 7, 5), nhưng các cuộc gọi với bốn lập luận và thậm chí thay đổi giá trị của biến.

The return value when you call substr($str, 7, 5,'you') is exactly the same as when you call substr($str, 7, 5), but the call with four arguments and even changed the value of the variable.

Tạo một chuỗi con của chuỗi ban đầu bằng cách ghép từng ký tự hoặc

A substring of the original by picking individual letters or