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
<?php $string = "beginning"; print("Position counted from left: ".substr($string,0,5)."\n"); print("Position counted form right: ".substr($string,-7,3)."\n"); ?>
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.