$original = 'lets_go_to_the_beach_today_my_friend'; $replace = str_replace('_', ' ', $original, $count); echo $count;