PMA\libraries\Util::parseEnumSetValues PHP Method

parseEnumSetValues() public static method

Parses ENUM/SET values
public static parseEnumSetValues ( string $definition, boolean $escapeHtml = true ) : array
$definition string The definition of the column for which to parse the values
$escapeHtml boolean Whether to escape html entities
return array
    public static function parseEnumSetValues($definition, $escapeHtml = true)
    {
        $values_string = htmlentities($definition, ENT_COMPAT, "UTF-8");
        // There is a JS port of the below parser in functions.js
        // If you are fixing something here,
        // you need to also update the JS port.
        $values = array();
        $in_string = false;
        $buffer = '';
        for ($i = 0, $length = mb_strlen($values_string); $i < $length; $i++) {
            $curr = mb_substr($values_string, $i, 1);
            $next = $i == mb_strlen($values_string) - 1 ? '' : mb_substr($values_string, $i + 1, 1);
            if (!$in_string && $curr == "'") {
                $in_string = true;
            } else {
                if ($in_string && $curr == "\\" && $next == "\\") {
                    $buffer .= "&#92;";
                    $i++;
                } else {
                    if ($in_string && $next == "'" && ($curr == "'" || $curr == "\\")) {
                        $buffer .= "&#39;";
                        $i++;
                    } else {
                        if ($in_string && $curr == "'") {
                            $in_string = false;
                            $values[] = $buffer;
                            $buffer = '';
                        } else {
                            if ($in_string) {
                                $buffer .= $curr;
                            }
                        }
                    }
                }
            }
        }
        if (strlen($buffer) > 0) {
            // The leftovers in the buffer are the last value (if any)
            $values[] = $buffer;
        }
        if (!$escapeHtml) {
            foreach ($values as $key => $value) {
                $values[$key] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
            }
        }
        return $values;
    }
Util