In what scenarios would using html_entity_decode be more appropriate than custom functions like rstrtrim for URL manipulation in PHP?

When dealing with URLs in PHP, using html_entity_decode would be more appropriate when you need to decode HTML entities in a URL string. This function is specifically designed to decode HTML entities, which may be present in URLs due to encoding issues. Custom functions like rstrtrim are more general and may not handle HTML entities specifically in URL manipulation scenarios.

// Example of using html_entity_decode to decode HTML entities in a URL string
$url = "https://www.example.com/page?param=value&another=123";
$decodedUrl = html_entity_decode($url);
echo $decodedUrl;