- preg_replace: documentation ( source)
<?php
$text = <<<TEXT
It's essential to keep your pup cool in the summer months! Try to keep them out of the heat as much as #possible - keep the house cool, #provide shade and run a #fan for them if #you can. #Dogs #Animals #Summer #DogCare #Humidity #HeatStroke #Cooling #HeatExhaustion #StayCool #HealthyPups
TEXT;
echo preg_replace('/ (?=(?:#[a-z]+\s*)+$)/i', "\n\n", $text, 1);