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!
Test code:
<?php
print "Starting.<br/>";
$scale = 100;
$coordinates_p = array();
$i = 0;
$x_coordinate = 1;
$y_coordinate = 2;
while ($i <= 1) {
$coordinates_p[$i] = array(0 => $x_coordinate, 1 => $y_coordinate);
$x_coordinate += 1;
$y_coordinate += 2;
$i++;
}
print "Unscaled: ";
print_r ($coordinates_p);
print "<br/>";
$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 "<br/>";
print "Finished.";
?>