This isn't intrinsically a WordPress query but here's the answer anyway. Just replace the value of $fruit with the corresponding fruit name which will then be used in your resulting array. if ($fruit=="1") { $fruit='Apples'; } elseif($fruit=="2") { $fruit='Cherries'; }