I want to define constants like this
$a = 0;
foreach ($data as $key) {
define('SN', array($key->SN));
define("CODE".$a, $key->Code);
$a++;
}
It works in php 7.0 but how to define it like this in php 5.4 ?
I want to define constants like this
$a = 0;
foreach ($data as $key) {
define('SN', array($key->SN));
define("CODE".$a, $key->Code);
$a++;
}
It works in php 7.0 but how to define it like this in php 5.4 ?
According to the docs at http://php.net/manual/en/function.define.php its not possile to use constants with array values.
The value of the constant. In PHP 5, value must be a scalar value (integer, float, string, boolean, or NULL). In PHP 7, array values are also accepted.