constant arrays
Source:
<?php
include "constant_array.class.php";
$CA = ConstantArray::getInstance();
$CA->define("someValues", array(1=>"een",2=>"twee",3=>"drie",4=>"vier"));
$CA->define("someValues[5][1][6][0]", "vijf");
$CA->define("someValues[5][1][6][3]", "vijf b");
var_dump($CA->someValues);
var_dump($CA->someValues[5][1][6]);
ConstantArray::define("moreValues", array(1=>"one", 2=>"two", 3=>"three", 4=>"four"));
var_dump(ConstantArray::constant("moreValues"));
ConstantArray::define("moreValues[4]", "cuatro");
var_dump(ConstantArray::constant("moreValues[4][5]"));
?>
Output:
array(5) {
[1]=>
string(3) "een"
[2]=>
string(4) "twee"
[3]=>
string(4) "drie"
[4]=>
string(4) "vier"
[5]=>
array(1) {
[1]=>
array(1) {
[6]=>
array(2) {
[0]=>
string(4) "vijf"
[3]=>
string(6) "vijf b"
}
}
}
}
array(2) {
[0]=>
string(4) "vijf"
[3]=>
string(6) "vijf b"
}
array(4) {
[1]=>
string(3) "one"
[2]=>
string(3) "two"
[3]=>
string(5) "three"
[4]=>
string(4) "four"
}
Notice: Constant 4 already defined in
C:\wamp\www\devshed\scripts\php\t\constant_array.class.php
on line 176
Notice: Use of undefined constant moreValues[4][5] in
C:\wamp\www\devshed\scripts\php\t\constant_array.class.php
on line 124
string(0) ""