[eluser]Swedie[/eluser]
New to CI and started making a method that uses views to display headers and footers from another website of mine. I've encountered a problem, maybe not specifically a CI issue, but an issue nevertheless that I must solve.
The problem being that if I include the header and footer, the swedish characters are turned into symbols:
* ���
* ���
* �#%�$?
If I leave out the header and footer, the swedish characters show up correctly. Thus the file_get_content or CI causes something to change. Why and how do I do this right?
Here is all my code!
Controller
Code:
<?php
/**
* Description of test
*
* @author Johnny
*/
class Test extends Controller {
var $website_url = "http://localhost:88";
function Test() {
parent::Controller();
}
function index()
{
$this->setHeaderAndFooter();
$data = array(
"header" => $this->header,
"footer" => $this->footer,
"title" => "Sveriges MotorCyklister",
"swedish_characters" => array("åäö", "ÅÄÖ", "¤#%£$€")
$this->load->view('test', $data);
}
function setHeaderAndFooter()
{
/* Scans main website for break points to put content
* @todo Save cache to db or file for faster and better control
*/
$page = file_get_contents($this->website_url);
$bits = explode("<!-- content start -->", $page);
$this->header = str_replace('"/', '"' . $this->website_url . '/', $bits['0']);
$bits = explode("<!-- content end -->", $bits['1']);
$this->footer = str_replace('"/', '"' . $this->website_url . '/', $bits['1']);
}
}
?>
The view file
Code:
<?=$header;?>
<ul>
<?php foreach($swedish_characters as $bit): ?>
<li><?=$bit;?></li>
<?php endforeach; ?>
</ul>
<?=$footer;?>