title: php - map a value using fromRange and toRange?
body: <p>I'm trying to figure out how to map a number between <em>1 and 1000</em> to a number between <em>1 and 5</em>. </p>
  
  <p>For example:</p>
  
  <p>I have a database of 1000 records and I want to assign an id number between 1 and 5 to each record. I don't want it to be random, thats easy enough with <code>rand(1,5)</code>.</p>
  
  <p>In the Arduino language it has a function that I'm hoping PHP has:</p>
  
  <pre><code>result = map(value, fromLow, fromHigh, toLow, toHigh)
  </code></pre>
  
  <p>The purpose of this is I don't want to store that mapped value in the database, I need a php function that I can call and if say the db record is 100 no matter how often the function is called it will always return the same mapped value.</p>
  
  <p>Thanks!</p>