code:
function updateGUI()
{
foreach ($GLOBALS['content_array'] as $i)
{
$title = $i[0];
$rating = $i[1];
echo "<li class=contentList><a class=contentListLink href=filmer_php.php?title=".$title."><span class=spantitle>".$title."</span><span class=spanrating>".asteriskifyRating($rating)."</span></a></li>";
}
}
output:
resources:
http://dist3.webbintro.se/assignments/3/movies.txt
context: So I'm creating <li>
with <a>
attached to them and I'm getting the $title
of the <li>
from a global variable (not important).
The problem is that the query string doesn't contain the full string as some $title
contain spaces, so they get cut off at the spaces. I've tried using escape characters \"
but didn't work and I can't find any good article about how to properly parse..
Also I would prefer if the solution didn't include regex, but if this can only be solved with regex then so be it.
EDIT1: context: Ok, urlencode fixed the biggest issue. I'm still getting a mojibake square before "Star Wars", any suggestion on what's causing this?
full code: http://jsfiddle.net/Uv5bV/
EDIT2: removed the utf-8 BOM, got the solution from this thread: How to remove multiple UTF-8 BOM sequences before "<!DOCTYPE>"?
code:
function remove_utf8_bom($text)
{
$bom = pack('H*','EFBBBF');
$text = preg_replace("/^$bom/", '', $text);
return $text;
}