How to remove portion of a string after a certain character in PHP?
0 24917
With the help of PHP substr() and strops() functions, we can remove the portion of a string after a certain character.
Example:
strpos():
It is an inbuilt function of PHP which searches a particular piece of text in a string and returns the first occurrence of that text.substr():
It is also an inbuilt function of PHP which returns the part of a string by position. We find the part of a string after a certain character with the help of above both functions.Example:
?php $string="coding-tag"; $position=strpos($string, "-"); $result=substr($string,intval($position)+1); echo $result; ?Output:

Share:





Comments
Waiting for your comments