What potential issues can arise when using substr() in PHP?

One potential issue when using substr() in PHP is that it may return an empty string if the start position provided is greater than the length of the input string. To solve this issue, you can check if the start position is within the bounds of the input string length before using substr().

$input_string = "Hello, World!";
$start_position = 20;

if ($start_position < strlen($input_string)) {
    $substring = substr($input_string, $start_position);
    echo $substring;
} else {
    echo "Start position is out of bounds.";
}