The P/E ratio isn't detached from the price of a share: it is derived from the price of a share divided by earnings per share.
And when you set up that equation what gets canceled out?
All that matters for the P/E ratio is the total market cap (the "P") and the total company earnings (the "E")...the (Price per Share)/(Earnings per Share) equation is simply an easy way to arrive at the number using widely-available value (share price and EPS) to simplify the math.