需要来自数组中的对象的字段php

时间:2017-03-14 12:58:18

标签: php arrays object

对于学校我制作了一个包含多个对象的数组,我需要对象中的字段内容。这是我的阵列:

Array
(
    [0] => Track Object
    (
        [ID:Track:private] => 107
        [Name:Track:private] => 
        [AlbumSource:Track:private] => Loose
        [Artist:Track:private] => 
        [Length:Track:private] => time Object
            (
                [hours:time:private] => 0
                [minutes:time:private] => 4
                [seconds:time:private] => 31
            )

        [style:Track:private] => Pop
    )

    [1] => Track Object
    (
        [ID:Track:private] => 107
        [Name:Track:private] => 
        [AlbumSource:Track:private] => 
        [Artist:Track:private] => 
        [Length:Track:private] => 
        [style:Track:private] => 
    )

)

我需要字段[Length:Track:private]的内容,我尝试了arraymaparray_column(),但我没有获得field的内容。

以下是Track类:

class Track{

    Private $ID;
    private $Name;
    private $AlbumSource;
    private $Artist;
    private $Length;
    private $style;

    const __default = "Pop";
    const Ambient = "Ambient";
    const Blues = "Blues";
    const Country = "Country";
    const Disco = "Disco";
    const Electro = "Electro";
    const Hardcore = "Hardcore";
    const HardRock = "HardRock";
    const HeavyMetal = "HeavyMetal";
    const Hiphop = "HIphop";
    const Jazz = "Jazz";
    const JumpStyle = "Jumpstyle";
    const Klassiek = "Klassiek";
    const Latin = "Latin";
    const Other = "Other";
    const Pop = "Pop";
    const Punk = "Punk";
    const Reggae = "Reggae";
    const Rock = "Rock";
    const Soul = "Soul";
    const Trance = "TRance";
    const Techno = "Techno";

    function __construct() {
        $argv = func_get_args();
        $args = func_num_args();

        switch($args) {
                case 0:
                    self::__construct0();
                    break;
                case 1:
                    self::__construct1($argv[0]);
                    break;
                case 2:
                    self::__construct2( $argv[0], $argv[1] );
                    break;
                case 3:
                    self::__construct3( $argv[0], $argv[1], $argv[2] );
        }
    }

    function __construct0() {
    }

    function __construct1($arg1) {
        $this->ID=$arg1;
    }

    function __construct2($arg1, $arg2) {
        $this->ID=$arg1;
        $this->Name=$arg2;
    }

    function __construct3($arg1, $arg2, $arg3) {
        $this->ID=$arg1;
        $this->Artist=$arg2;
        $this->Name=$arg3;
    }

    public function getID() {
        return $this->ID;
    }

    public function setID($arg1) {
        $this->ID=$arg1;
    }

    public function getName(){
        return $this->Name;
    }

    public function setName($arg1){
        $this->Name=$arg1;
    }

    public function getArtist() {
        return $this->Artist;
    }

    public function setArtist($arg1){
        $this->Artist=$arg1;
    }

    public function getLength(){
        return $this->Length;
    }

    public function setLength($arg1) {
        $this->Length = $arg1;
    }

    public function setStyle($arg1){
        $this->style=$arg1;
    }

    public function getStyle() {
        return $this->style;
    }

    public function getAlbumSource() {
        return $this->AlbumSource;
    }

    public function setAlbumSource($arg1){
        $this->AlbumSource=$arg1;
    }

}

0 个答案:

没有答案