PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr

PHP-Scripte PHP-Tutorials PHP-Jobs und vieles mehr (https://www.php-resource.de/forum/)
-   PHP Developer Forum (https://www.php-resource.de/forum/php-developer-forum/)
-   -   Form a unique numerical value from enumeration (https://www.php-resource.de/forum/php-developer-forum/106630-form-a-unique-numerical-value-from-enumeration.html)

Lincon 03-06-2019 19:01

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?

chorn 08-06-2019 14:12

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


Alle Zeitangaben in WEZ +2. Es ist jetzt 07:27 Uhr.

Powered by vBulletin® Version 3.8.2 (Deutsch)
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
[c] ebiz-consult GmbH & Co. KG