BENTONVILLE, ARK. — The impact of the current inflationary environment on consumers is embedded in Walmart Inc.’s second-quarter results. Strong food sales supported a 1% growth in quarterly transactions while average tickets rose 5.5%, according to the company. Notably, Walmart’s customer base in the United States grew during the period.

“In the Walmart US business, we have seen mid- to higher-income customers come to Walmart looking for value,” said C. Douglas McMillon, president and chief executive officer, during an Aug. 16 conference call to discuss second-quarter results. “As you would expect, food and consumables, in particular, are places where they're looking to save some money. That's not a total surprise. I think the strength of it is encouraging.”

John David Rainey, chief financial officer, said consumers searching for value manifested in a variety of ways.

“As an example, instead of deli meats at higher price points, customers are increasing purchases of hot dogs as well as canned tuna or chicken,” he said. “Private brand penetration has also inflected higher. And in the food category, specifically the private brand growth rate doubled compared to Q1 levels. We'll continue to manage pricing for customers in a way that preserves our price gaps and allows us to earn market share profitably.”

For the second quarter ended July 31, Walmart’s net income rose 20% to $5.2 billion, equal to $1.88 per share on the common stock, and up from $4.3 billion, or $1.53 per share, the year before.

Quarterly sales rose 8% to $151.2 billion.

“The second quarter finished stronger than we had anticipated,” Mr. McMillon said. He added that while inflation remains high, most of Walmart’s markets are growing comps ahead of inflation.

Walmart US sales were $105 billion, up 7% when compared with the second quarter of the previous year. The business unit’s operating income fell 7% to $5.7 billion.

“Food sales were especially strong with mid-teens growth while general merchandise sales were soft, particularly in electronics, apparel and home,” Mr. Rainey said.

For the year, Walmart said it still expects consolidated net sales growth to be approximately 4.5%. The company also updated its operating income outlook, now saying it expects it to decline 9% to 11% versus the previous outlook that it would decline 11% to 13%. The improvement reflects a better-than-expected performance during the second quarter, the company said.

“I think what you should take away from Q3 and Q4 guidance is that we're expecting the environment to look a lot like Q2,” Mr. McMillon said.