mardi 4 août 2015

Excluding/Including items from one array based on values from another

I have two arrays, one containing hashes, the other integers. They look like this (samples):

mainArray[0] = {"ID" => 23, "NAME" => "SALLY"}
mainArray[1] = {"ID" => 34, "NAME" => "BILL"}

idArray[0] = 432
idArray[1] = 34

I want to filter mainArray so that only entries in it whose ID values are in idArray make the cut. How can I best do this? I don't mind making a new array if that helps.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire