HecKel Posted September 28, 2009 at 03:58 PM Report Share #289019 Posted September 28, 2009 at 03:58 PM Boas pessoal! Estou aqui com um problema que não estou a conseguir resolver (duh), tenho o seguinte ficheiro php: menus.php: <?php $xmlstr = <<<XML <?xml version="1.0" encoding="UTF-8"?> <menus> <top> <item active='false' id='0'> <name>teste</name> <url>/url.php</url> </item> <item active='true' id='1'> <name>Contactos</name> <url>/contactos.php</url> </item> </top> <left> <item active='true' id='2'> <name>grupo</name> <url>/grupo.php</url> <submenus> <item active='false' id='20'> <name>direcção</name> <url>/grupo/direccao.php</url> </item> </submenus> </item> </left> </menus> XML; ?> Isto acho que basta index.php: <?php include 'menus.php'; $xml = new SimpleXMLElement($xmlstr); $var = '3'; foreach ($xml->top[0]->item as $item) { if ($item['active']=='true') { echo '<a href="'. $item->url .'">'. $item->name .'</a><br />'; } } foreach ($xml->left[0]->item as $item) { if ($item['active']=='true') { echo '<a href="'. $item->url .'">'. $item->name .'</a><br />'; if($item['id'] == $var) { foreach ($item->submenus[0]->item as $subitem) { if ($subitem['active']=='true') { echo 'submenu: <a href="'. $subitem->url .'">'. $subitem->name .'</a><br />'; } } } } } ?> Aconteceu que a palavra direcção aparece sempre como direcção. Ambos os ficheiros estão em UTF8, portanto também não vejo como o problema pode ser daí. Ideias? Look Left Blog Link to comment Share on other sites More sharing options...
HecKel Posted September 28, 2009 at 04:17 PM Author Report Share #289020 Posted September 28, 2009 at 04:17 PM Resolvido, n tinha colocado o encoding em html. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> thanks fnds 😄 Look Left Blog Link to comment Share on other sites More sharing options...
fnds Posted September 28, 2009 at 04:19 PM Report Share #289021 Posted September 28, 2009 at 04:19 PM De nada 😄 Link to comment Share on other sites More sharing options...
yoda Posted September 29, 2009 at 08:39 AM Report Share #289132 Posted September 29, 2009 at 08:39 AM Para garantir que o browser mete as cenas com o encoding correcto, usa antes a função header() do php, é mais fiável que o markup. before you post, what have you tried? - http://filipematias.info sense, purpose, direction Link to comment Share on other sites More sharing options...
fnds Posted September 29, 2009 at 11:07 PM Report Share #289272 Posted September 29, 2009 at 11:07 PM Para garantir que o browser mete as cenas com o encoding correcto, usa antes a função header() do php, é mais fiável que o markup. Exacto, não me lembrei disso! Assim até podes cagar no que envias para o browser. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now