Bam Margera[1] was readmitted into a rehab facility just hours after his bizarre arrest at an L.A. hotel -- TMZ has learned -- and this time around he'll have to follow some serious guidelines.

Sources close to Bam tell us ... immediately after he was released from police custody, he was readmitted to rehab. The facility is demanding a commitment from him, along with various rules he must follow during his treatment. We're told he's agreed to all conditions.

Bam was first admitted[2] to rehab last week after he publicly reached out to Dr. Phil[3] and begged for help. The two did a sit-down interview and he was supposed to enter a 60-90 day program ... but he lasted less than a week.

TMZ broke the story ... Bam was arrested in L.A.[4] early Wednesday morning at a Sunset Strip hotel. Cops say they were called to the hotel after Bam got into it with other hotel guests, and refused to leave the property.

This video shows the craziness surrounding the arrest. You hear an officer telling Bam, "This is not a f**king reality TV show. I know you're fresh out of rehab, so let's get your s**t together." Bam had been spinning a weird tale for bar patrons -- that he'd been hired by one of their wives to catch someone at the bar cheating on her.

We've spoken to family sources who tell us they're worried sick[5] over Bam's health and safety ... telling us they believe he's off his bipolar meds, which is exacerbating his bizarre behavior[6].

Read more from our friends at TMZ