Home > Backend Development > PHP Tutorial > How to obtain a substring in php based on the specified position and length, php string_PHP tutorial

How to obtain a substring in php based on the specified position and length, php string_PHP tutorial

WBOY
Release: 2016-07-13 10:02:47
Original
934 people have browsed it

php method to obtain a substring based on the specified position and length, php string

The example in this article describes the method for php to obtain a substring based on the specified position and length. Share it with everyone for your reference. The specific analysis is as follows:

PHP’s substr function is very powerful. You can constantly remove substrings from front to back, and you can also take strings from back to front

<&#63;php
$string = "beginning";
print("Position counted from left: ".substr($string,0,5)."\n");
print("Position counted form right: ".substr($string,-7,3)."\n");
&#63;>
Copy after login

Output result:

Position counted from left: begin
Position counted form right: gin
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969502.htmlTechArticlephp method to obtain a substring based on the specified position and length, php string The example in this article tells about php based on the specified position and length methods to obtain substrings. Share it with everyone for your reference...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template