You can easy extend the html function as described at
https://ellislab.com/codeigniter/user-gu...lpers.html
For you example you have to create a new file called MY_html_helper.php in the "/application/helper" directory with the following content:
Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
if ( ! function_exists('meta'))
{
/**
* Generates meta tags from an array of key/values
*
* @param array
* @param string
* @param string
* @param string
* @return string
*/
function meta($name = '', $content = '', $type = 'name', $newline = "\n")
{
// Since we allow the data to be passes as a string, a simple array
// or a multidimensional one, we need to do a little prepping.
if ( ! is_array($name))
{
$name = array(array('name' => $name, 'content' => $content, 'type' => $type, 'newline' => $newline));
}
elseif (isset($name['name']))
{
// Turn single array into multidimensional
$name = array($name);
}
$str = '';
foreach ($name as $meta)
{
$type = (isset($meta['type']) && $meta['type'] !== 'name') ? $meta['type'] : 'name';
$name = isset($meta['name']) ? $meta['name'] : '';
$newline = isset($meta['newline']) ? $meta['newline'] : "\n";
$content = (isset($meta['content']) && !empty($meta['content'])) ? 'content="'.$meta['content'].'" /' : '';
$str .= '<meta '.$type.'="'.$name.'" '.$content.'>'.$newline;
}
return $str;
}
}
Now you can us this helper like that:
Code:
$this->load->helper('html');
echo meta('utf8', '', 'charset');