Tools, FAQ, Tutorials:
Taking a Substring in PHP
How To Take a Substring from a Given String?
✍: FYIcenter.com
If you know the position of a substring in a given string, you can take the substring out by the substr() function. Here is a PHP script on how to use substr():
<?php $string = "beginning"; print("Position counted from left: ".substr($string,0,5)."\n"); print("Position counted form right: ".substr($string,-7,3)."\n"); ?>
This script will print:
Position counted from left: begin Position counted form right: gin
substr() can take negative starting position counted from the end of the string.
2016-10-13, 841👍, 0💬
Popular Posts:
How to create Hello-3.0.epub with WinRAR? I have all required files to create Hello-3.0.epub. To cre...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...
What is EPUB 2.0 Metadata "dc:creator" and "dc:contributor" elements? EPUB 2.0 Metadata "dc:creator"...
What Is session_register() in PHP? session_register() is old function that registers global variable...
How to access Request body from "context.Request.Body" object in Azure API Policy? Request body is t...