How to output label instead of value from select list?

Created on 21 July 2014, over 10 years ago

I have a select list with key/labels like this:
1|married
2|single

I'm setting a variable like this to get the value:
$mstatus = $entity->field_marital_status[LANGUAGE_NONE][0]['value'];

This outputs the value as: 1 or 2 correctly.

How do i print the label itself though so i can do something like "You are $mstatus" so it displays as "You are married" instead of "You are 1"?

πŸ’¬ Support request
Status

Fixed

Version

1.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States apmsooner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024