I am running a query on a dbase that returns a multi-field recordset or array on fetch. The array is multi-field as I need several fields to output to the screen. However, I then want to save an array of just one variable, the id for each record. to compare against another list of records. So I need to, in effect, strip all but one field from the array.
In effect, I want to reduce (not using proper array notation):
{1 red dog, 2 orange cat, 3 yellow canary}
to
{1,2,3}
Is there an easy way to do this?
Thanks in advance!
Basically what you want is called array plucking; here’s an RFC to introduce this into the language, but it hasn’t been accepted.
In the meantime you’d just have to do it the old fashioned way:
Before 5.3 you’d have to write it like so: