А база данных, не вариант? Зачем этот велосипед?
sqlfiddle.com/#!9/9b7f4/2/0CREATE TABLE IF NOT EXISTS `first` (
`name` varchar(50) CHARACTER SET utf8 NOT NULL,
`key` varchar(50) CHARACTER SET utf8 NOT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE IF NOT EXISTS `second` (
`key` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
`value` varchar(50) CHARACTER SET utf8 DEFAULT NULL,
KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `first` (`name`, `key`) VALUES
('color', 'green'),
('color', 'red'),
('color', 'blue');
INSERT INTO `second` (`key`, `value`) VALUES
('green', 'apple'),
('red', 'cherry'),
('blue', 'sky');
SELECT
CONCAT(f.`name`,':',s.value) AS result,
FROM `first` AS f
INNER JOIN `second` AS s ON s.`key` = f.`key`;