In this PHP tutorial, you shall learn how to delete the first character from given string using substr() function, with example programs.
PHP – Delete first character in string
To delete first character from a string in PHP, we can find the substring from index=1 to end of the string. Call
substr() function and pass the given string, and an integer value of 1 as arguments.
The syntax to get the string
str without its first character using
substr() function is
The function returns a string value.
1. Remove first character of a string
In this example, we will take a string
str and find an output string which is made from
str but without the first character.
<?php $str = 'apple'; $output = substr($str, 1); echo $output; ?>
In this PHP Tutorial, we learned how to delete the first character of a string, using