Search code examples
phpcodeignitercodeigniter-hmvc

How to get function return array single line ? Below my code


Class:

 class profile_setting extends MY_Controller {

    public function __construct()
    {
        parent::__construct();
    }
    public function index()
    {
        echo $this->table()->breadcrump;
    }
    public function table(){
        return array('table'=>'tbl_users','breadcrump'=>'Profile Settings','redirect_url'=>'dashboard');
    }
}

Above code i got error when i use this single line like below

echo $this->table()->breadcrump; or echo $this->table()['breadcrump'];


Solution

  • Try with -

    $breadcrumb = $this->table();
    echo $breadcrumb['breadcrump'];
    

    for single line try with -

    echo $this->table()['breadcrump'];