Hi,
Using PHP 4.4.4, I have a class defined like so
class CUserItem {
var $m_id;
var $m_children_arr ;
function CUserTOCItem($p _id)
{
$this->m_id = $p_id;
$this->m_children_a rr = array();
} // CUserItem
function addChild($p_chi ld) {
array_push($thi s->m_children_arr , $p_child);
} // addChild
function numChildren() {
return count($this->m_children_arr );
} // numChildren
} // CUserItem
then in a separate bit of code, I have an associative array of
objects, with the key being the id and the value being the object.
Unfortunately, when I try and manipulate the objects in the array, it
doesn't take ...
$item = new CUserItem(1);
$item2 = new CUserItem(2);
$toc_items_arr[1] = $item;
$item->addChild($item 2);
print $toc_items_arr[1]-
The "print" line should print out "1" because I have added a child.
But it does not. What's going wrong? - Dave
Using PHP 4.4.4, I have a class defined like so
class CUserItem {
var $m_id;
var $m_children_arr ;
function CUserTOCItem($p _id)
{
$this->m_id = $p_id;
$this->m_children_a rr = array();
} // CUserItem
function addChild($p_chi ld) {
array_push($thi s->m_children_arr , $p_child);
} // addChild
function numChildren() {
return count($this->m_children_arr );
} // numChildren
} // CUserItem
then in a separate bit of code, I have an associative array of
objects, with the key being the id and the value being the object.
Unfortunately, when I try and manipulate the objects in the array, it
doesn't take ...
$item = new CUserItem(1);
$item2 = new CUserItem(2);
$toc_items_arr[1] = $item;
$item->addChild($item 2);
print $toc_items_arr[1]-
>numChildren( ); // still prints zero!
But it does not. What's going wrong? - Dave
Comment