Hướng dẫn dùng strspn trong PHP
Hàm Show Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức. Hàm trả về số nguyên là số kí tự tồn tại trong danh sách các kí tự truyền vào, và xuất hiện liên tiếp từ đầu chuỗi nguồn. Cú phápCú pháp: Trong đó: Bài viết này được đăng tại [free tuts .net]
Ví dụCode $str = "abcd efgh iklm"; echo strspn($str, 'ab') . " Tham khảo: php.net
Hướng dẫn cách sử dụng hàm strspn() trong lập trình PHP Tác dụng của hàm strspn()The The following table summarizes the technical details of this function.
SyntaxThe basic syntax of the strspn(string, mask, start, length); The following example shows the
ParametersThe
More ExamplesHere're some more examples showing how If string does not start with any characters specified in the mask, this function returns 0.
The following example returns the length of the initial portion of the string that consists only of characters contained within "Her". Let's try it out and see how it works:
In the following example only the portion "World" of the string will be examined, because the position to start searching is 6 and the length of the string to search is 5.
Bài viết này đã giúp ích cho bạn?Bài viết mớiHàm Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức. Hàm trả về số nguyên là số kí tự tồn tại trong danh sách các kí tự truyền vào, và xuất hiện liên tiếp từ đầu chuỗi nguồn. Cú phápCú pháp: Trong đó: Bài viết này được đăng tại [free tuts .net]
Ví dụCode $str = "abcd efgh iklm"; echo strspn($str, 'ab') . " Tham khảo: php.net
Hướng dẫn cách sử dụng hàm strspn() trong lập trình PHP Tác dụng của hàm strspn()The The following table summarizes the technical details of this function.
SyntaxThe basic syntax of the strspn(string, mask, start, length); The following example shows the
ParametersThe
More ExamplesHere're some more examples showing how If string does not start with any characters specified in the mask, this function returns 0.
The following example returns the length of the initial portion of the string that consists only of characters contained within "Her". Let's try it out and see how it works:
In the following example only the portion "World" of the string will be examined, because the position to start searching is 6 and the length of the string to search is 5.
Bài viết này đã giúp ích cho bạn?Bài viết mới❮ Tham chiếu chuỗi PHP Thí dụTrả về số ký tự được tìm thấy trong chuỗi "Hello world!" có chứa các ký tự "kHlleo": echo
strspn("Hello world!","kHlleo"); Định nghĩa và Cách sử dụngHàm strspn () trả về số lượng ký tự được tìm thấy trong chuỗi chỉ chứa các ký tự từ tham số charlist. Mẹo: Sử dụng hàm strcspn () để trả về số ký tự được tìm thấy trong một chuỗi trước khi tìm thấy bất kỳ phần nào của các ký tự được chỉ định. Lưu ý: Hàm này là an toàn nhị phân. Cú phápstrspn(string,charlist,start,length) Giá trị tham số
Chi tiết kỹ thuật
Các ví dụ khácThí dụTrả về số ký tự được tìm thấy trong chuỗi "abcdefand" có chứa các ký tự "abc": echo strspn("abcdefand","abc"); ❮ Tham chiếu chuỗi PHP |