PHP substr() to Extract a Part of a String

Created At: 2022-04-09 13:36:08 Updated At: 2022-04-09 13:42:30

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

See the substr() structure


First one for mentioning the string, 

Second one is for where to start to,

Third one is for how many strings to keep,

echo substr("Hello world dbestech ",0, 6);

The output is


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


Add Reviews