jeudi 2 juin 2016

Php If Condition in Array

I am trying to built an if condition in my array currently looks like this but does not work.

protected $menuItems = [
    'items' => [
        [
            'title' => 'test',
        ],
        $this->hasma() ? [
            'title' => 'Ma',
        ] : null,
    ],
]

Basically hasma returns true or false, if it is true it shall add the above and if it is false I shall return (add) nothing.

Aucun commentaire:

Enregistrer un commentaire