Form a unique numerical value from enumeration

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Form a unique numerical value from enumeration

    Hello everyone,,
    I know that from the time VB6 + WinApi. Unfortunately, that is so long ago that I almost forgot everything again. At any rate, you could tie different values ​​together and then use logical operators to query whether value X occurs in the total value. The total value can also contain several numbers.

    Here is a code example as I imagine:

    <? Php

    abstract class ENUM_TEST {
    const VALUE_1 = 0x10;
    const VALUE_2 = 0x20;
    const VALUE_3 = 0x30;
    const VALUE_4 = 0x40;
    const VALUE_5 = 0x50;
    const VALUE_6 = 0x60;
    const VALUE_8 = 0x70;
    const VALUE_9 = 0x80;
    const VALUE_10 = 0x90;
    const VALUE_11 = 0x100;
    const VALUE_12 = 0x110;
    }

    // calculate value
    $ target = consists of ENUM_TEST :: VALUE_5 and ENUM_TEST :: VALUE_12, for example.

    // query values
    Is $ target value from ENUM_TEST :: VALUE_12?

  • #2
    you could use an array and a function like array_intersect to check on containing values.

    https://www.php.net/manual/en/functi...-intersect.php

    Kommentar

    Lädt...
    X