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.

php

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…

PROCESAMIENTO AJAX EN SCRIPTCASE

Ajax en los formularios de Scriptcase puede usarse para recargar un campo de tipo de select basado e...

IMPORTAR IMAGENES DE LA BASE DE DATOS Y UTILIZAR CLASES DE BOOSTRAP

Como muchas personas ya saben, Bootstrap es una biblioteca de front-end libre y de código abierto p...

TENDENCIAS DE DESARROLLO WEB PARA 2017

Usted verá en este post tendencias para 2017 en Diseño Web, en el medio digital y en el desarrollo...

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 sales@scriptcase.net. Learn more about our Privacy Police.