How can strrpos and substr functions in PHP be used to manipulate strings effectively?
To manipulate strings effectively using strrpos and substr functions in PHP, you can use strrpos to find the position of the last occurrence of a substring within a string, and then use substr to extract a portion of the string based on that position. This can be useful for tasks like extracting file extensions from file names or extracting specific parts of a string based on a delimiter.
$string = "Hello, World!";
$lastCommaPosition = strrpos($string, ",");
$substring = substr($string, $lastCommaPosition + 1);
echo $substring; // Outputs "World!"