In PHP we use....
foreach ($array as $value) {
echo $value;
}
In Java the same thing can be done using
for (int e : array) {
System.out.println(e);
}
is there any difference between the above 2 code segments
In PHP we use....
foreach ($array as $value) {
echo $value;
}
In Java the same thing can be done using
for (int e : array) {
System.out.println(e);
}
is there any difference between the above 2 code segments
This is very close to what both forms of java for-each iterator (numeric and Iterator) do, but PHP iterator also can provide keys and bind the iterated value by-reference, so you could modify it in place if you wanted to.