Sanheim finished a 2-on-0 rush with Sean Couturier after Blues forward Brayden Schenn fell in the neutral zone.
Rodrigo Abols and Tyson Foerster scored, and Travis Konecny had two assists for Philadelphia (10-6-3). Dan Vladar made 27 saves.
Justin Faulk scored two goals for St. Louis (6-9-6), which lost its fourth straight game. Joel Hofer made 25 saves.
Faulk made it 1-0 at 5:31 of the first period with a one-timer from the right point through traffic.
The Blues went ahead 2-0 at 12:08 on Faulk’s power-play goal from the top of the left face-off circle. Jake Neighbours, back after missing 12 games because of a right leg injury, had an assist on the goal.
Abols made it 2-1 at 17:57 of the second when he scored from in front off a pass from behind the net by Owen Tippett.
Foerster tied the game 2-2 at 11:49 of the third period with a one-timer from the left face-off circle after Flyers defenseman Emil Andrae held a clearing attempt in at the blue line.