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:

$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:

$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.

You might also like…

What advantages for a company in adopting a low-code tool?

Let's understand how low-code tools have become a facilitator in the web development process as they...

How to implement A2F using Swivel in a Scriptcase application

I want to start talking about Swivel, Swivel is a provider of authentication solutions who have been...

Comments, tips and interactions inside Scriptcase.

Hello, here are some tips, comments and interactions about database and tools like HTML, CSS, JavaSc...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at Learn more about our Privacy Police.