Add 2 values to 1 key in a PHP array

Posted by Mike Munroe on Stack Overflow See other posts from Stack Overflow or by Mike Munroe
Published on 2010-06-17T21:54:11Z Indexed on 2010/06/17 22:03 UTC
Read the original article Hit count: 605

Filed under:
|
|

I have a result set of data that I want to write to an array in php. Here is my sample data:

**Name** **Abbrev**
Mike     M
Tom      T
Jim      J

Using that data, I want to create an array in php that is of the following:

1|Mike|M
2|Tom|T
3|Jim|j

I tried array_push($values, 'name', 'abbreviation') [pseudo code], which gave me the following:

1|Mike
2|M
3|Tom
4|T
5|Jim
6|J

I need to do a look up against this array to get the same key value, if I look up "Mike" or "M".

What is the best way to write my result set into an array as set above where name and abbreviation share the same key?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays