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
WBOYOriginal
2016-07-13 10:02:47938browse

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;>

Output result:

Position counted from left: begin
Position counted form right: gin

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...
Statement:
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