php increment operator when pre pending string -
im not sure why next occurs in php
<?php //make array first $example = array(); $i = 0; while($i < 10) { $example[$i++] = $i; } var_dump($example); //looks here. expected $i = 0; while ($i < 10) { $example[$i] = $i . " " . $example[$i++]; } var_dump($example); //this 1 should contain each of values 1 time again illustration $expected = array( "0 0", "1 1", "2 2", //etc );
when doing same in java
public class append { public static void main(string[] args) { string[] array = new string[10]; int = 0; while (i < 10) { array[i] = i++ + ""; } = 0; while (i < 10) { array[i] = + " " + array[i++]; } = 0; while(i < 10) { system.out.println (array[i++]); } } }
it returns correct, thing can think of operator precedence. because [
out ranks ++
in php , in java ++
outranks ?
sorry theres lot of code, thought explain improve
php increment post-increment
No comments:
Post a Comment