In exclusive video obtained by Action News, the man speaks to the camera as he is being brought into the Cheltenham police station.
"I'm sorry, man. I thought somebody was going to kill me," the suspect says in the video.
Investigators said after a dispute occurred at the checkout line, the suspect pulled a gun from a female companion's waistband and opened fire.
Dozens of people were inside the store at the Cedarbrook Plaza shopping center as the gunman opened fire around 6 p.m.
Twelve-year-old Nicholas Hatcher was recording video on his cell phone when suddenly the first shot rang out. His mom, Rachel Suarez, said they made a dash for the door.
"Everybody ran, and then the alarm came on," said Suarez. "I started to run. I was scared for my life."
Jaynee Davis, a nurse, said she tended to one of the shooting victims.
"We didn't know if the shooter was in the store," Davis said. "We were petrified."
One Walmart employee told Action News her colleague was shot in the leg and was screaming: "I'm shot, I'm shot."
According to officials, at least five people were injured in the incident, with three suffering gunshot wounds to the legs, one person with a graze wound on their leg and a pregnant woman who fell while running from the scene. They were all taken to area hospitals.
First responders descended upon the scene. Witnesses told authorities the gunman sped off in a 2001 gold-colored Pontiac Grand Prix.
Investigators said after tossing the gun out of the car in the area of Stenton and Mt. Pleasant avenues, the Pontiac crashed into a police cruiser just blocks from the Walmart at East Sedgewick and Forrest. The officers in the cruiser just happened to be in the area responding to an unrelated incident.
"It was a good job by Philadelphia police who happened to be at the right place at the right time; they made this arrest initially thinking they were arresting somebody for trying to leave the scene of an auto accident and then realizing it's a much more serious crime, a triple shooting," Philadelphia Police Chief Inspector Scott Small said.
Police said following his apprehension, the male suspect attempted to kick out the window of the police vehicle and was subsequently shocked by officers with a stun gun. He was transported to Einstein Medical Center.
The two officers in the police car that was struck were taken to Roxborough Memorial Hospital with minor injuries.
A 25-year-old woman was later arrested for her involvement in the shooting. Police say she was holding the gun when the shooter grabbed it from her.
A total of eight EMS agencies and 22 police departments, including Philadelphia police and the Montgomery County SWAT team, assisted with the incident.
Walmart issued the following statement concerning the incident Tuesday night:
"We are relieved that an arrest has been made and thankful that injuries sustained by three of our associates and a customer are non-life threatening. Local authorities acted quickly and did an outstanding job. Our focus remains on supporting our associates and continuing to assist law enforcement."
Officials said the store will reopen Wednesday morning.
The incident remains under investigation.