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

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2