EXETER, Calif. — About the same time Hollywood’s remake of 1980s TV show “21 Jump Street” opened in cinemas across the US last week, California police made a series of arrests thanks to an undercover operation resembling its plot.

For eight months, a 22-year-old police officer posed as a high school student in Exeter, in California’s Central Valley, the Los Angeles Times reported.

The unnamed officer, who was enrolled at Exeter Union High School under the pseudonym Johnny Ramirez, did everything a student would — he attended classes, he did homework, he hung out with other students.

He was also studying the school’s drug problem as part of a wider police investigation.

“He would come into the narcotics investigations office and do homework,” City Manager Randy Groom said. “Then he would start on his police reports.”

The undercover operation paid off last week, as police arrested 13 students, aged 15 to 19, on drug-related charges.

“He was very clearly a good choice for this,” Groom said. “He looks like he’s 15 years old. He still has braces on.”

Groom said the officer was plucked out of the police academy specifically for this investigation because of his youthful looks. Only three school officials, two police officers and Groom knew about the undercover mission.

The officer’s cover was almost blown on his first day when a teacher, who was unaware of the operation, pointed to the new kid and joked they had “an undercover narc officer” in the room.

As he began to fit in, the officer told other students he had been expelled from a neighboring school district. He would leave school at lunch every day, telling his new school friends he needed to help an uncle run a business — but really he was reporting to the police narcotics lab.

The 10,000 residents of Exeter were shocked by news of the operation. Not one of his fellow students suspected he was a police officer, until he arrived back on campus last week, in uniform, to make the arrests, the Times reported.

“21 Jump Street,” which ran from 1987 to 1991, focused on a group of young police officers whose work generally consisted of undercover work in high schools. The TV show launched the career of Johnny Depp.

It was remade into a film starring Jonah Hill and Channing Tatum — earning an estimated $35 million in its opening weekend and topping the box office just a few days ago.