PHP substr() to Extract a Part of a String

substr() function is used when you want to remove part of the string. It takes three parameters.

See the substr() structure

substr(string,start,length);

First one for mentioning the string, 

Second one is for where to start to,

Third one is for how many strings to keep,

<?php
echo substr("Hello world dbestech ",0, 6);
?>

The output is

hello

The above function starts to count the string from the 0th character and keep 6 of them and remove rest of them. 

Recent posts