code: private static function getIndexRowByCurrencyFromApplePriceMatrix(\DOMXPath $xpath, $currency)
      {
          $trElements = $xpath->query('//table[1]//tr');
  
          if ($currency === 'EUR') {
              $currency = 'Euro';
          }
  
          if ($trElements->length < 2) {
              throw new \RuntimeException('Invalid table structure.');
          }
  
          // Search all "td" elements
          /** @var \DOMElement[] $currencyElements */
          $currencyElements = $xpath->query('//table[1]//tr[2]/td');
  
          $index = 0;
  
          foreach ($currencyElements as $currencyElement) {
              if ($currency === trim($currencyElement->textContent)) {
                  return $index;
              }
  
              $index++;
          }
  
          throw new \RuntimeException(sprintf(
              'Not found currency by code "%s" in ApplePriceMatrix.',
              $currency
          ));
      }
docs: Get index row by currency from \DOMDocument (ApplePriceMatrix)
  
  @param \DOMXPath $xpath
  @param string $currency
  
  @return int
  
  @throws \RuntimeException