anotherJEK
02-29-2012, 10:01 PM
I am trying to load a multidimensional array into an object property.
I have found that, in this context, the object array property cannot be literally
set to a provided array argument
// this works in a __constructor
foreach($_imageDirs as $this->ind=>$this->val)
{
self::$_localImgDirs[$this->ind] = $this->val;
}
// whereas (both are arrays)
self::$_localImgDirs = $_imageDirs // does not work
So, I have been trying to read in a multidimensional array in the
__construct method.
// $_imgArrayList is an associative array of associative arrays
// which exists in an external, require_once('file')
foreach($_imgArrayList as $this->ind=>$this->val)
{
self::$_localImgLists[$this->ind] = array();
foreach($_imgArrayList[$this->ind] as $this->inda=>$this->vala)
{
self::$_localImgLists[$this->ind][$this->inda] = $this->vala;
}
}
I have been trying various versions, without success:
Any suggestions?
Thanks for time and attention
JK
I have found that, in this context, the object array property cannot be literally
set to a provided array argument
// this works in a __constructor
foreach($_imageDirs as $this->ind=>$this->val)
{
self::$_localImgDirs[$this->ind] = $this->val;
}
// whereas (both are arrays)
self::$_localImgDirs = $_imageDirs // does not work
So, I have been trying to read in a multidimensional array in the
__construct method.
// $_imgArrayList is an associative array of associative arrays
// which exists in an external, require_once('file')
foreach($_imgArrayList as $this->ind=>$this->val)
{
self::$_localImgLists[$this->ind] = array();
foreach($_imgArrayList[$this->ind] as $this->inda=>$this->vala)
{
self::$_localImgLists[$this->ind][$this->inda] = $this->vala;
}
}
I have been trying various versions, without success:
Any suggestions?
Thanks for time and attention
JK