Cody Glass scored for the Devils (40-35-3), who were eliminated from playoff contention. Jacob Markstrom made 14 saves.
"It's difficult, it's embarrassing, I don't like it," Devils coach Sheldon Keefe said. "I've coached for 20 years, this is the first time I won't be participating in the playoffs at any level. So it's not fun. I've never been in a situation like this, but we've earned this. It is what it is."
Zegras gave the Flyers a 1-0 lead 1:56 into the game, scoring from the right circle off a pass from Travis Sanheim. Owen Tippett started the play by cycling around the net and passing to Sanheim in the left circle.
Zegras scored his second of the period for a 2-0 lead with a power-play goal at 3:38, tipping in a pass from Porter Martone.
Zegras had his fifth two-goal game of the season and tied his career high in points with 65. Acquired in the offseason from the Anaheim Ducks, the six-year veteran has yet to play in the playoffs.
"Right from the beginning when Trevor came to us, he wanted to play meaningful games," Flyers coach Rick Tocchet said. "I hate using the word 'playoffs' but he wants to make the playoffs, right? He hasn't played a playoff game. I think he wants to prove a lot of people wrong. He played with a chip on his shoulder this year."
Glass got the Devils within one at 12:12 when Jonas Siegenthaler's shot from the slot deflected off a jumping Glass, then off Vladar's mask and into the net.
Foerster made it 3-1 at 2:46 of the second period, scoring on a 2-on-1 with Tippet when he kept the puck and took a wrist shot from the right circle.