How can the problem of not replacing the first number in a line be resolved when using str_replace in PHP?

When using str_replace in PHP to replace a specific number in a line, the issue of not replacing the first number can be resolved by using the limit parameter in the str_replace function. By setting the limit parameter to 1, only the first occurrence of the number will be replaced.

$string = "12345 67890";
$replacement = "0";
$new_string = str_replace("1", $replacement, $string, 1);
echo $new_string; // Output: "02345 67890"