Taking a Substring in PHP
How To Take a Substring from a Given String?
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, 1057👍, 0💬
How to write a policy to set and get custom variables? Here is a policy that sets and gets custom va...
How Values in Arrays Are Indexed in PHP? Values in an array are all indexed their corresponding keys...
How to add a new operation to an API on the Publisher Dashboard of an Azure API Management Service? ...
What is Azure API Management Developer Portal Admin? The Developer Portal Admin is an Azure Web port...
How to add request body examples to my Azure API operation to make it more user friendly? If you hav...