1

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'];

Yes Kay Selva
  • 584
  • 4
  • 14

4 Answers4

1

Try with -

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

for single line try with -

echo $this->table()['breadcrump'];
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
0

I think this should work for you in single line.

 public function index()
 {
   echo $this->table()['breadcrump'];
 }

Demo

Sadikhasan
  • 18,365
  • 21
  • 80
  • 122
0

The simplest way I found to do bread crumbs on codeigniter is. You can use this with bootstrap is well.

public function index()

    $data['breadcrumbs'] = array();

    $data['breadcrumbs'][] = array(
        'text' => 'Home',
        'href' => site_url('admin/common/dashboard')
    );

    $data['breadcrumbs'][] = array(
        'text' => 'Banners',
        'href' => site_url('admin/design/banners')
    );

  $this->load->view('folder/file', $data); 
}

On view

<ul class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
    <?php } ?>
</ul>
0

Sadikhasan and sgt have given you the answer as you are accessing an array you have to use that way.

if the return was a object then you have to use this way $this->table()->breadcrump

But for this you are accessing an returned array so @Sadikhasan 's answer is your answer.

Anton Perera
  • 353
  • 3
  • 9