Thread: Array Indexes
View Single Post
Old 08-13-2007   #2 (permalink)
Marco Shaw


 
 

Re: Array Indexes

Shay Levi wrote:
>
> The following returns all array items that equels to 3
>
> PS C:\Scripts> @(1,2,3,5,3,2) -eq 3
> 3
> 3
>
> How can I get the index numbers instead of the item content (i.e., 2,4)?
>
>
> Shay
> http://scriptolog.blogspot.com
>
>


arrays don't seem to have a lot of members to work with...

You just need a simple solution?

$i=0;@(1,2,3,5,3,2)|foreach-object{if($_ -eq 3){$i};$i++}

Marco

--
----------------
PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec