How can you properly replace double quotes with " in PHP?

When working with strings in PHP, if you need to replace double quotes with the HTML entity for double quotes ("), you can use the str_replace function. This function allows you to specify the string you want to replace, the string you want to replace it with, and the original string. By replacing double quotes with ", you can ensure that the string is properly formatted for display in HTML.

$string = 'This is a "sample" string with double quotes';
$fixed_string = str_replace('"', '"', $string);
echo $fixed_string;