One of the most common methods when working with String is the SUBSTRING, through it you can delete part of a string from a position. In most programming languages, this method gets the position where the string needs to be “cut” in PHP works exactly in this format.
In PHP using the substr() you can pass as parameters the string that will be crafted and also from that point will be breaking the string, check out the example below:
<?php
$string = “thisisastring”;
$substr1 = substr($string, 4);
echo (“Text: “. $substr1);
?>
The result of this operation will be “isastring”.
Otherwise using the substr() can not only delete but also say the lenght of the new string. Check out the example:
<?php
$string = “thisisastring”;
$substr1 = substr($string, 4, 8);
echo (“Text: “. $substr1);
?>
The result of this operation will be “isastrin” where the cut starts from the fourth character and the string will have the lenght 8.
Using this method you can perform many activities of daily programming. Test this and other functions in PHP in Scriptcase in our development tool takes you not only to study methods that do not know and all the features that can make your everyday life much more agile. Access the e-learning section of our site and learn more, download the free version now Scriptcase and start enjoying right now all the advantages that this offers fantastic tool.
Comment this post