US prices rose in April at their fastest rate since May 2023 as the impact of the war in Iran was increasingly felt by consumers.