How can string manipulation be effectively used in PHP to replace specific characters in a path or URL?

When working with paths or URLs in PHP, you may need to replace specific characters for various reasons such as encoding or decoding. String manipulation functions like `str_replace()` can be effectively used to replace specific characters in a path or URL. By using `str_replace()`, you can easily search for a specific character or substring and replace it with another character or substring.

// Example of replacing specific characters in a path or URL
$path = "/images/example image.jpg";
$newPath = str_replace(" ", "%20", $path);

echo $newPath; // Output: "/images/example%20image.jpg"