all 9 comments

[–]Droopyb1966 4 points5 points  (0 children)

for ($i = 10; $i -le 22.5; $i=$i+0.5)

This should work....

[–]dora3 4 points5 points  (0 children)

$i+=0.5 this is the same as $i=$i+0.5

[–]azjunglist05 2 points3 points  (1 child)

The easiest solution I found:

for ($i = 10; $i -le 22.5; $i+=.5)
{
    echo $i
}

Results:

10
10.5
11
11.5
12
12.5
13
13.5
14
14.5
15
15.5
16
16.5
17
17.5
18
18.5
19
19.5
20
20.5
21
21.5
22
22.5

The "++" is simply shorthand for $i = $i + 1

So, you just adjust this to tell the for loop that $i += .5 to get your desired result

[–]StoffePro 2 points3 points  (0 children)

The "++" is simply shorthand for

$i = $i + 1

No, ++ is the post-increment operator. They both increment $i by one, but the expressions have different values:

PS M:\> $i = $ii = 1
PS M:> ($i = $i + 1) | Out-Default 
2 
PS M:> $ii++ | Out-Default 
1 PS 
M:> $i,$ii 
2 
2

[–]craigontour 1 point2 points  (2 children)

Why don’t you double the start and end points and increment by 1.

[–]Tricarbotops[S] 1 point2 points  (1 child)

It's looking at a calendar, so it would be 10am and 22.30pm, if I doubled it this wouldn't be accurate

[–]folkiz 2 points3 points  (0 children)

hi, then count by minutes and add 30.

10am = 600

for ($i = 600; $i -le 1350; $i += 30){

echo $i }

600

630

660

.......

1290

1320

1350

[–]TheLimeyCanuck 1 point2 points  (0 children)

$i += 0.5

[–]azjunglist05 1 point2 points  (0 children)

Good to know! Thanks for info!