I have a multidimensional array where I am storing a variable as the key and a list of file names within the array.
Below is some test code I am using:
$file["dir1"] = "dir1";
$file["dir2"] = "dir2";
$fileDetails = new FileInformation();
$fileDetails->fileName = "file1";
$fileDetails->fieSize = 100;
$fileDetails->modifiedTime = "111";
$file["dir1"][0] = $fileDetails;
$fileDetails = new FileInformation();
$fileDetails->fileName = "file2";
$fileDetails->fieSize = 200;
$fileDetails->modifiedTime = "222";
$file["dir1"][1] = $fileDetails;
The FileInformation class is defined as follows:
class FileInformation
{
var $fileName;
var $modifiedTime;
var $fieSize;
}
On the line $file["dir1"][0] = $fileDetails; I am getting the following error from PHP:
Catchable fatal error: Object of class FileInformation could not be converted to string in
I'm not sure what the problem is, I'm sure I've done this before in the past or at least something similar.
The idea is if I want to get the fileName out from the array then I could do the following:
$file["dir1"][0]->fileName
At least this is how I am expecting it to work.
varanymore,public, private, protectedis much better