title: How to multiply elements of php array
body: <p>I'm trying to translate a javascript function into php but having some problems with my arrays.  I need to iterate over the array elements, multiplying them all by a certain amount, but it's not changing the values.  Pretty sure it's because my syntax $coordinates_p[i][0] *= $scale; isn't correct, but I'm not sure what it should be!</p>
  
  <p>Test code:</p>
  
  <pre><code>&lt;?php
  
  print "Starting.&lt;br/&gt;";
  
  $scale = 100;
  
  $coordinates_p = array();
  
  $i = 0;
  $x_coordinate = 1;
  $y_coordinate = 2;
  while ($i &lt;= 1) {
      $coordinates_p[$i] = array(0 =&gt; $x_coordinate, 1 =&gt; $y_coordinate);
      $x_coordinate += 1;
      $y_coordinate += 2;
      $i++;
  }
  
  print "Unscaled: ";
  print_r ($coordinates_p);
  print "&lt;br/&gt;";
  
  $i = 0;
  while (isset($coordinates_p[i])) {
      $coordinates_p[i][0] *= $scale;
      $coordinates_p[i][1] *= $scale;
      $i++;
  }
  
  print "Scaled: ";
  print_r ($coordinates_p);
  print "&lt;br/&gt;";
  
  print "Finished.";
  
  ?&gt;
  </code></pre>