Answer the question
In order to leave comments, you need to log in
How to access nested array elements in PHP?
Good afternoon.
Please help me understand how to work with nested arrays in PHP.
class skill
{
public $id=0;
public $name="";
public $glyphs=array();
public function __construct($id,$name)
{
$this->id=$id;
$this->name=$name;
}
}
class glyph
{
public $id;
public $skill_id;
public $name;
public $description;
public $cost;
public $lvl_req;
public $icon;
public function __construct($id,$skill_id,$name,$description,$cost,$lvl_req)
{
$this->id=$id;
$this->skill_id=$skill_id;
$this->name=$name;
$this->description=$description;
$this->cost=$cost;
$this->lvl_req=$lvl_req;
$this->icon="/images/glyphs".$name."png";
}
}
class player
{
public $class;
public $level;
public $skills=array();
public $points;
}
$player->skills[$i]->glyphs[j];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question