[eluser]gtech[/eluser]
take a look at the template parser class, its aim is to remove the need for php in the view files.
[url="http://ellislab.com/codeigniter/user-guide/libraries/parser.html"]http://ellislab.com/codeigniter/user-guide/libraries/parser.html[/url]
You can even use arrays (or variable pairs as they are labeled in the docs) which you build up in the controller, avoiding the need to use a foreach loop in the view. Its simple to use and the documentation is good and to the point.
example from docs:
view:
Code:
<body>
<h3>{blog_heading}</h3>
{blog_entries}
<h5>{title}</h5>
<p>{body}</p>
{/blog_entries}
</body>
controller:
Code:
$this->load->library('parser');
$data = array(
'blog_heading' => 'My Blog Heading',
'blog_entries' => array(
array('title' => 'Title 1', 'body' => 'Body 1'),
array('title' => 'Title 2', 'body' => 'Body 2')
)
);
// instead of using $this->load->view
$this->parser->parse('blog_template', $data);