The strchr Function
The strchr
function finds the first occurrence
of a substring in a string and returns the part of the string
starting from that location to the end of the string. If
the second parameter consists of more than one
character, only the first character is used.
Syntax
strchr(string $haystack, string $needle, bool $before_needle = false): string|false
Example . Usage
Let's extract the page address without the domain
name from the URL (will return the substring, starting from
the first /
, to the end of the string)
<?php
echo strchr('site.ru/dir1/dir2/page.html', '/');
?>
Code execution result:
'/dir1/dir2/page.html'