Hey this is a pretty old topic, but I have a similar problem that isn't fixed by this here. I'm currently programming what will eventually be a fully automated site for a computer gaming league, and I was having a problem with taking an array in and assigning it as a variable in a class. I'm a past C++ programmer, and I really havn't used PHP that much, so I'm just wondering if there's a quirky language problem I don't know about. I'm so against stealing scripts I won't even take a news system without knowing exactly what happens.
Anyways here's my code:
class newspost
{
var $poster;
var $timestamp;
var $title;
var $content;
function set($poster, $timestamp, $title, $content)
//This function sets this newspost to the input values
{
$this->poster=$poster;
$this->timestamp=$timestamp;
$this->title=$title;
$this->content=array();
$this->content=$content;
//for ($i=0;$i<count($content);$i++)
// $this->content[$i]=$content[$i];
echo "$content[0]";
echo "$this->content[0]";
}
//... more functions
}
Basically what happens is the array inside the class ($this->content) isn't set to what the input array is ($content). I've tried multiple ways of assigning it, including array_slice and that commented out 'for' loop, but they all do the same thing, which is nothing. The first test echo outputs the correct value, but the second one just puts: Array[0]