title: Match a value with an XML et un CSV et change it
body: <p>I need to change a value in a XML (is a value of a price). I get this XML in the same repository of my file PHP.</p>
  <p>For do that, i have 1 file XML where there is the value that i want change (there are multiple products), and a .CSV with three columns (this CSV also is in the same repository of the index.php):</p>
  <ul>
  <li>Column A and Column B rapresent a range of weight</li>
  <li>Column C is the price that i want take for change the value in XML.</li>
  </ul>
  <p>Example:</p>
  <pre><code>    XML
      &lt;weight&gt;2.5&lt;/weight&gt;
      &lt;price&gt;5&lt;/price&gt;
  
      CSV
      | COLUMN A| COLUMN B| COLUMN C|
  
      |:---- |:------:| -----:|
  
      | 2     | 3     | 5      |
  </code></pre>
  <p>So in that case i need to add 5 from column C in the value of XML &quot;price&quot;.</p>
  <p>Now, i need to convert the XML (but also the CSV ) in a multidimensional array like that:</p>
  <pre><code>[1] 
       COLUMN A =&gt; 1
       COLUMN B =&gt; 2
       COLUMN C =&gt; 5
  [2]  
       COLUMN A =&gt; 2
       COLUMN B =&gt; 3
       COLUMN C =&gt; 10
    ...  
  </code></pre>
  <p>The idea is doin a loop in the XML multidimensional array and a second loop in the CSV array and get the COLUMN C if the weight is beetween COLUMN A and COLUMN B.</p>
  <p>The problem is that i son't know how convert the XML and the CSV into the array with KEY (COLUMN A) =&gt; VALUE (1).</p>
  <p>I used simplexml_load_file for the XML and fgetcsv  for the CSV, but is not what i need.</p>
  <p>Can you help me on doing that  Thank you !</p>
  <p>That s my code:</p>
  <pre><code>&lt;?php
  function getXmlToArray (string $xmlName) {
      $xml=simplexml_load_file($xmlName) or die(&quot;&lt;br/&gt;Errore di caricamento&lt;br/&gt;&quot;);
      return $xml;
  }
  
  function getDeliveryPrice(){
      $csv = 'prezzi_spedizione_francia.csv';
      $file = fopen($csv, 'r');
  
      while (!feof($file) ) {
          $arrayCsv[] = fgetcsv($file, 1024);
      }
      fclose($file);
      return $arrayCsv;
      
  
  }
  
  
  $xml = getXmlToArray(&quot;pre-FR_1.xml&quot;);
  $listaPrezzi = getDeliveryPrice();
  </code></pre>
  <p>XML</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;Products&gt;
    &lt;Product&gt;
      &lt;sku&gt;35&lt;/sku&gt;
      &lt;sku_manufacturer&gt;FIN 260182300000&lt;/sku_manufacturer&gt;
      &lt;manufacturer&gt;Finder&lt;/manufacturer&gt;
      &lt;ean&gt;8012823238074&lt;/ean&gt;
      &lt;title&gt;&lt;![CDATA[Finder interrupteur à impulsion relais 230v 26018230]]&gt;&lt;/title&gt;
      &lt;description&gt;&lt;![CDATA[&lt;p&gt;Finder 230v relais &lt;span&gt;électromécanique à impulsion avec circuit bobine et contacts séparés avec 1 contact NO&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Caractéristiques :&lt;/strong&gt;&lt;/p&gt;
  &lt;ul&gt;&lt;li&gt;Nombre de contacts 1NO&lt;/li&gt;
  &lt;li&gt;Courant nominal/ Courant instantané max. 10/20A&lt;/li&gt;
  &lt;li&gt;Tension nominale/Tension maximale de commutation 250/400 VAC&lt;/li&gt;
  &lt;li&gt;Charge nominale en AC1 2500VA&lt;/li&gt;
  &lt;li&gt;Charge nominale en AC15 (230 V AC) 500VA&lt;/li&gt;
  &lt;li&gt;Charge de commutation minimale 1000 (10/10) mW (V/mA)&lt;/li&gt;
  &lt;li&gt;Matériau de contact standard AgNi&lt;/li&gt;
  &lt;li&gt;Tension d'alimentation nominale (UN) 230 V AC (50 Hz)&lt;/li&gt;
  &lt;li&gt;Isolation entre la bobine et les contacts (1,2/50 μs) 4 kV&lt;/li&gt;
  &lt;li&gt;Température ambiante -40...+40 degrés&lt;/li&gt;
  &lt;li&gt;Degré de protection IP20&lt;/li&gt;
  &lt;/ul&gt;&lt;p&gt;&lt;strong&gt;Capacité de la lampe&lt;/strong&gt;&lt;/p&gt;
  &lt;ul&gt;&lt;li&gt;Incandescent/halogène 230 V 800 W&lt;/li&gt;
  &lt;li&gt;Fluorescents avec ballast électronique 400W&lt;/li&gt;
  &lt;li&gt;Fluorescents avec ballast électromagnétique déphasé 360W&lt;/li&gt;
  &lt;li&gt;CFL 200W&lt;/li&gt;
  &lt;li&gt;LED 230 V 200W&lt;/li&gt;
  &lt;li&gt;Halogène ou BT LED avec transformateur électronique 200W&lt;/li&gt;
  &lt;li&gt;Halogène ou LED BT avec transformateur électromagnétique de 400W&lt;/li&gt;
  &lt;/ul&gt;&lt;p&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;b&gt;Typologie &lt;/b&gt; : Relais&lt;/li&gt;&lt;li&gt;&lt;b&gt;Type&lt;/b&gt; : Interrupteur&lt;/li&gt;&lt;li&gt;&lt;b&gt;Installation&lt;/b&gt; : Encastré&lt;/li&gt;&lt;/ul&gt;]]&gt;&lt;/description&gt;
      &lt;product_price_vat_inc&gt;10.08&lt;/product_price_vat_inc&gt;
      &lt;shipping_price_vat_inc&gt;0&lt;/shipping_price_vat_inc&gt;
      &lt;quantity&gt;3233&lt;/quantity&gt;
      &lt;brand&gt;&lt;![CDATA[Finder]]&gt;&lt;/brand&gt;
      &lt;merchant_category&gt;&lt;![CDATA[Accueil/Automatisation/Automatisation domestique]]&gt;&lt;/merchant_category&gt;
      &lt;product_url&gt;&lt;![CDATA[https://www.elettronew.com/fr/automatisation-domestique/finder-interrupteur-a-impulsion-relais-230v-26018230-35.html]]&gt;&lt;/product_url&gt;
      &lt;image_1&gt;&lt;![CDATA[https://www.elettronew.com/35872/finder-interrupteur-a-impulsion-relais-230v-26018230.jpg]]&gt;&lt;/image_1&gt;
      &lt;image_2&gt;&lt;![CDATA[]]&gt;&lt;/image_2&gt;
      &lt;image_3&gt;&lt;![CDATA[]]&gt;&lt;/image_3&gt;
      &lt;image_4&gt;&lt;![CDATA[]]&gt;&lt;/image_4&gt;
      &lt;image_5&gt;&lt;![CDATA[]]&gt;&lt;/image_5&gt;
      &lt;retail_price_vat_inc/&gt;
      &lt;product_vat_rate&gt;22&lt;/product_vat_rate&gt;
      &lt;shipping_vat_rate&gt;20&lt;/shipping_vat_rate&gt;
      &lt;manufacturer_pdf/&gt;
      &lt;ParentSKU/&gt;
      &lt;parent_title/&gt;
      &lt;Cross_Sell_Sku/&gt;
      &lt;ManufacturerWarrantyTime/&gt;
      &lt;use_grid&gt;1&lt;/use_grid&gt;
      &lt;carrier&gt;Courrier DHL Standard (FR)&lt;/carrier&gt;
      &lt;shipping_time&gt;2#4&lt;/shipping_time&gt;
      &lt;carrier_grid_1&gt;Courrier DHL Standard (FR)&lt;/carrier_grid_1&gt;
      &lt;shipping_time_carrier_grid_1&gt;2#5&lt;/shipping_time_carrier_grid_1&gt;
      &lt;carrier_grid_2/&gt;
      &lt;shipping_time_carrier_grid_2/&gt;
      &lt;carrier_grid_3/&gt;
      &lt;shipping_time_carrier_grid_3/&gt;
      &lt;carrier_grid_4/&gt;
      &lt;shipping_time_carrier_grid_4/&gt;
      &lt;carrier_grid_5/&gt;
      &lt;shipping_time_carrier_grid_5/&gt;
      &lt;DisplayWeight&gt;0.050000&lt;/DisplayWeight&gt;
      &lt;free_return/&gt;
      &lt;min_quantity&gt;1&lt;/min_quantity&gt;
      &lt;increment&gt;1&lt;/increment&gt;
      &lt;sales&gt;0&lt;/sales&gt;
      &lt;eco_participation&gt;0&lt;/eco_participation&gt;
      &lt;shipping_price_supplement_vat_inc&gt;0&lt;/shipping_price_supplement_vat_inc&gt;
      &lt;Unit_count&gt;-1.000000&lt;/Unit_count&gt;
      &lt;Unit_count_type/&gt;
    &lt;/Product&gt;
  
  CSV
  COLUMN A;COLUMN B;COLUMN C
  0;1;14,5
  1;2;20
  2;3;21
  3;4;22
  4;5;23
  5;6;23,5
  6;7;23,5
  7;8;25
  8;9;26
  9;10;27
  </code></pre>