Programmer
Programmer

Reputation: 157

Display the result of a function in codeigniter view

In the index function of my controller I am calling getDirContents and I need to display the result of $data['arrDirContents'] in view

public function index()
    {
        $this->accesscontrol->can_or_redirect('view', 'translation');
        $dir = './application/language/english';
        $data['arrDirContents']=$this->getDirContents($dir, "~^.+_lang\.php$~i");
        $this->output->view('translation/language',$data);
    }

Any help on how to get the result of that function in view?

Upvotes: 0

Views: 641

Answers (2)

Programmer
Programmer

Reputation: 157

$this->load->vars( array(
   'arrDirContents'=>$this->getDirContents($dir, "~^.+_lang\.php$~i")
));

Upvotes: 0

Vinoth Smart
Vinoth Smart

Reputation: 403

<?php $dir = './application/language/english'; $data['arrDirContents']=$this->getDirContents($dir, "~^.+_lang\.php$~i"); ?>

If this values contents single value means

In View Page just do echo

<?php echo $arrDirContents; ?>

If this values contents multiple value having array value Do foreach print each variable value

<?php
foreach( $arrDirContents as $directs):
    echo $directs;
endforech;
?>

Upvotes: 1

Related Questions