<?php class get_c_str { var $str; var $start_str; var $end_str; var $start_pos; var $end_pos; var $c_str_l; var $contents; function get_str($str, $start_str, $end_str) { $this->str = $str; $this->start_str = $start_str; $this->end_str = $end_str; $this->start_pos = strpos($this->str, $this->start_str) + strlen($this->start_str); $this->end_pos = strpos($this->str, $this->end_str); $this->c_str_l = $this->end_pos - $this->start_pos; $this->contents = substr($this->str, $this->start_pos, $this->c_str_l); return $this->contents; } }
This is a PHP class for intercepting strings. Friends who need it can download it and use it.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
20 Jul 2016
PHP string interception function. PHP tutorial string interception function There is a string interception function substr in PHP, but this function can only intercept English and does not support Chinese and other mixtures. Below we provide three functions
13 Jul 2016
Support sharing of PHP string interception functions in Chinese and other encodings (interception of Chinese strings). Simple string interception method, supports Chinese and other encodings, just call it directly by passing in the corresponding parameters. Copy the code. The code is as follows: /** * String interception, supports Chinese and other encodings.
25 Jul 2016
PHP Chinese string interception PHP interception Chinese string code
25 Jul 2016
PHP interception string function, PHP custom string interception method
22 Nov 2016
Published: sunday01 Source: net Read: 2 [Large Medium Small] When PHP intercepts Chinese strings, it generally determines whether it is a double-byte character based on whether the value is greater than or equal to 128 to avoid incomplete interception and garbled characters. However, when encountering situations where Chinese and English are mixed and special symbols are included, the problem is not so easy to solve. The following is a function that comprehensively solves the problem of Chinese string interception. Friends in need can refer to it. Note: 1. The len parameter is based on Chinese characters. 1len is equal to 2 English characters...
22 Nov 2016
Published: sunday01 Source: net Read: 2 [Large Medium Small] When PHP intercepts Chinese strings, it generally determines whether it is a double-byte character based on whether the value is greater than or equal to 128 to avoid incomplete interception and garbled characters. However, when encountering situations where Chinese and English are mixed and special symbols are included, the problem is not so easy to solve. The following is a function that comprehensively solves the problem of Chinese string interception. Friends in need can refer to it. Note: 1. The len parameter is based on Chinese characters. 1len is equal to 2 English characters...
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images