by axew3 » Mon Sep 05, 2016 8:52 pm
Php 7 - Define: "Defines a named constant at runtime. In PHP 7, array values are also accepted."
But prior PHP 7, you can maybe do this, using a
constant to pass an array elsewhere with define:
Code: Select all
$to_define_array = serialize($array);
define( "DEFINEANARRAY", $to_define_array );
... and so ...
Code: Select all
$serialized = DEFINEANARRAY; // passing directly the defined constant to unserialize() will not work
$our_array = unserialize($serialized);
print_r($our_array);
Php 7 - Define: "Defines a named constant at runtime. In PHP 7, array values are also accepted."
[b]But prior PHP 7[/b], you can maybe do this, using a [i]constant[/i] to pass an array elsewhere with define:
[code]$to_define_array = serialize($array);
define( "DEFINEANARRAY", $to_define_array );[/code]
... and so ...
[code]
$serialized = DEFINEANARRAY; // passing directly the defined constant to unserialize() will not work
$our_array = unserialize($serialized);
print_r($our_array);[/code]