Detox is where they medically withdraw you from whatever substance you may be using.
In the case of alcohol and benzodiazepines (xanax, valium, etc) it is medically necessary because sudden withdrawal from these substances can cause seizures (alcohol and benzos) or heart arrhythmias (alcohol) .
Opiates will make you physically ill (nausea, vomiting, chills, diarrhea, abdominal and muscle cramps) but the withdrawal isn't life threatening. However, addicts, generally, can't tolerate the symptoms and will use to abate them, so they require medical support to decrease the symptoms so they won't use.
Other things like cocaine and meth are only psychologically addictive, but the addict will need extra psychological support to get through the withdrawal period.
The length of detox from alcohol and benzos depends on the addict and how heavily they are using. Rebel's son may only need a few days if he really did just relapse and drink for 2 days. He may not even require any medical intervention, but they want to monitor to be safe.
PHP is more of an inpatient type rehab. Unlike IOP (Intensive Outpatient Program) the addicts aren't out in the community. They stay at the facility and focus on recovery. That may be 2 weeks or a month. Depends.