title: How to define a custom key in PHP arrays?
body: <p>I want to define a two dimension array like below:</p>
  
  <pre><code>   [40.1][John]
     [40.2][Jane]
     [40.7][Mary]       
     [40.10][Sara]    
  </code></pre>
  
  <p>in other words I want to define an array with custom key. Later I need to access to the array values with the custom key. for instance : </p>
  
  <pre><code>   echo(myarray[40.2]);
  </code></pre>
  
  <p>And I need to generate the array dynamically from XML , since the values are coming from a XML file.
  The XML file which I want to generate the array from is like below:</p>
  
  <pre><code>    &lt;rules&gt;
  
  &lt;rule&gt;
      &lt;id&gt;40.1&lt;/id&gt;
      &lt;regex&gt;&lt;![CDATA[/(?:\)\s*when\s*\d+\s*then)/]]&gt;&lt;/regex&gt;
  &lt;/rule&gt;
  &lt;rule&gt;
      &lt;id&gt;40.2&lt;/id&gt;
      &lt;regex&gt;&lt;![CDATA[/(?:"\s*(?:#|--|{))/]]&gt;&lt;/regex&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>How should I create the array with above characteristics?</p>