PodsField_Pick::value_to_label PHP Method

value_to_label() public method

Get the label from a pick value
Since: 2.2
public value_to_label ( string $name, string | array $value = null, array $options = null, array $pod = null, integer $id = null ) : string
$name string The name of the field
$value string | array The value of the field
$options array Field options
$pod array Pod data
$id integer Item ID
return string
    public function value_to_label($name, $value = null, $options = null, $pod = null, $id = null)
    {
        if (isset($options['options'])) {
            $options = array_merge($options, $options['options']);
            unset($options['options']);
        }
        $data = pods_var_raw('data', $options, null, null, true);
        $object_params = array('name' => $name, 'value' => $value, 'options' => $options, 'pod' => $pod, 'id' => $id, 'context' => 'value_to_label');
        if (null !== $data) {
            $data = (array) $data;
        } else {
            $data = $this->get_object_data($object_params);
        }
        $labels = array();
        foreach ($data as $v => $l) {
            if (!in_array($l, $labels) && ($value == $v || is_array($value) && in_array($v, $value))) {
                $labels[] = $l;
            }
        }
        $labels = apply_filters('pods_field_pick_value_to_label', $labels, $name, $value, $options, $pod, $id);
        $labels = pods_serial_comma($labels);
        return $labels;
    }