I have a problem with in_array using newly introduced array class constants. When I put a class constant which contains an array into the function I get a warning:
Warning: in_array() expects parameter 2 to be array, unknown given in...
Code:
foreach ($fields as $key => $value) {
if (in_array($key, self::FIELDS)) $this->$key = $value;
}
Constant (inside a class):
const FIELDS = [
self::FIELD_ID,
self::FIELD_STREET,
self::FIELD_HOUSE_NR,
self::FIELD_POSTCODE,
self::FIELD_CITY,
self::FIELD_PERSONAL_NUMBER,
self::FIELD_SELLER_NAME,
'empty'
];
The weirdest part of this problem is that it works on my local machine without any errors/warnings (Mac) running PHP 5.6.2 but does not on my server also running PHP 5.6.2.
How do I resolve this error? (I don't want to use static arrays...)