within an object function, this code:
$test2[]='test';
echo "$test[0]";
$this->test2[]='test2';
echo "$this->test2[0]\n";
produces this result:
test2
Array[0]
Why do I get Array[0] instead of the value in Array[0] ?
This only seems to happen when the variable is part of an array in an
object. If, for example, I want to wrap an object's variable in single
quotes this doesn't work:
"'$this->test2[0]'"
I can put double quotes areound the single quotes:
"'".$this->test2[0]."'"
but in a long string this becomes very tedious:
"$this->name=['".$this->mbox[0]."','".$this->mbox[1]."',".$this->mbox[2]."];";
is there any way to get "'$this->test2[0]'" to work ?
red
$test2[]='test';
echo "$test[0]";
$this->test2[]='test2';
echo "$this->test2[0]\n";
produces this result:
test2
Array[0]
Why do I get Array[0] instead of the value in Array[0] ?
This only seems to happen when the variable is part of an array in an
object. If, for example, I want to wrap an object's variable in single
quotes this doesn't work:
"'$this->test2[0]'"
I can put double quotes areound the single quotes:
"'".$this->test2[0]."'"
but in a long string this becomes very tedious:
"$this->name=['".$this->mbox[0]."','".$this->mbox[1]."',".$this->mbox[2]."];";
is there any way to get "'$this->test2[0]'" to work ?
red
Comment