Remove hyperlinks ( A tag) from HTML

Sometimes we want to remove hyperlinks with anker text, sometimes only keep anker text, how to use php to achive this?

First, only remove hyperlink, and keep anker text part, the code is:

$text = ‘Test paragraph.’;
echo strip_tags($text);