Array position where new value starts
hi,
i have array $a contains id in different frequency, , sorted. want know "array position" id number changes. array given here result i'm looking - 0,4,9,12
array ($a):
1001
1001
1001
1001
1002
1002
1002
1002
1002
1003
1003
1003
1004
1004
1004
hi,
you can solve follow:
# multiline for($i = 0;$i -lt $a.count;$i++) { if($a[$i] -ne $a[$i-1]) { $i } } # oneliner for($i = 0;$i -lt $a.count;$i++){if($a[$i] -ne $a[$i-1]){$i}}
malte
Windows Server > Windows PowerShell
Comments
Post a Comment