The young footballers rescued from a flooded cave in Thailand lost weight during their 18-day ordeal but had water while they were trapped and are in good health, a health official has said.

The 12 boys and their coach – rescued over three days – “took care of themselves well in the cave”, public health inspector Thongchai Lertwilairatanapong said at the hospital in Chiang Rai where the group is recovering.

Four boys rescued on Sunday can eat normal food and walk around, and the four pulled out on Monday are eating soft food.

Mr Thongchai said one member of the final group of four boys and the coach who arrived at the hospital on Tuesday evening had a slight lung infection. Two of the first group had a lung infection as well, and he said they would need medicine for seven days.

The average weight loss was 4.4lb for those with known information, he added. They found water dripping inside the cave.

Celebrations after the evacuation in Chiang Rai Celebrations after the evacuation in Chiang Rai (Sakchai Lalit/AP)

The group entered the sprawling Tham Luang cave to go exploring after football practice on June 23, but monsoon rains filled the tight passageways, blocking their escape.

They were found by a pair of British divers 10 days later, huddled on a small, dry shelf just above the water, smiling with relief but visibly skinny.

The complex, high-risk mission for international and Thai divers to guide the boys and coach through the cave’s tight, flooded passageways had riveted people worldwide.

Highlighting the dangers, Saman Kunan, a former Thai navy diver volunteering to work on the rescue, died on Friday while replenishing oxygen canisters.

Thailand cave rescue (PA Graphics)

Prime minister Prayuth Chan-ocha has thanked people involved in the rescue, saying the government’s efforts, the assistance of people in Thailand and abroad, and the outpouring of moral support made the mission a success.

He also acknowledged the loss of Mr Saman, adding: “His honour, sacrifice and legacy will forever be in our hearts.”

The boys, aged 11 to 16 and with no diving experience, were guided out by a pair of divers though rocky, muddy and wateru passages that in places were just a crawl space.

The method was extremely risky, but dwindling oxygen levels in the cave and fears of more rain made a decision urgent. Relatively mild weather and a massive effort to pump out water created a window of opportunity, and the confidence of the diving team, and expertise specific to the cave, grew after its first successful mission on Sunday.

Students pray at Maesaiprasitsart school where six of the rescued boys study Students pray at Maesaiprasitsart school where six of the rescued boys study (Johnson Lai/AP)

The boys are in isolation in hospital to prevent infections by outsiders, but family members have seen some of them from behind a glass screen, and after a period of time with no problems, the family members will be allowed closer while dressed in sterilised clothing.

Health officials have said the boys will have a mental health evaluation to address any problems caused by their ordeal. Outside experts have said the group identity of the team-mates and their youth will aid their ability to recover.