# Using an array to pull values from another array

**URL:** <https://forum.kirupa.com/t/using-an-array-to-pull-values-from-another-array/312289>\
**Category:** programming\
**Created:** [July 29, 2010, 7:37pm UTC](https://forum.kirupa.com/t/using-an-array-to-pull-values-from-another-array/312289 "2010-07-29T19:37:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![W92Baj](https://avatars.discourse-cdn.com/v4/letter/w/a88e4f/32.png) [@W92Baj](https://forum.kirupa.com/u/W92Baj)\
**Post date:** [July 29, 2010, 7:37pm UTC](https://forum.kirupa.com/t/using-an-array-to-pull-values-from-another-array/312289/1 "2010-07-29T19:37:48Z")

</div>

I have 2 long arrays of items, say 20 or so, as a constant items included on a page.  
On individual pages I want to use another array to take the values from a certain number of positions (the same) within both constants.

If I had the ability to use sql in this instance it would be easy but I do not have that luxury.

eg

```php

//constant arrays
$numbers (1, 2... 19, 20);
$alphabeticalFood (apple, banana... sausage, tramploine);
 
//Choice array
$selector (1, 3, 5)
 
Something something
 
Output: 
2 4 6 //(135 would be nicer)
banana durian frankfurter //(again apple, carrot, egg would be preferable)
 
 

```

I have tried with foreach’s and thought about multidimensional arrays but frankly my little brain gets lost.

Anyone got any good ideas or a nice little function that will do the job?
