Zander
Zander

Reputation: 1086

PhP get first letter as symbol �

This problem is the strangest thing I've seen for a while.

I got all pages in UTF-8, adding the <meta> as charset="UTF-8" in the index page, and even header().

Then I got a page where I add all the link from the top menu in an array, so it's scalable when showing the list.

$menu['services'] = "Services";
    $submenu['services']['sendings'] = "International sendings";
    /* And more like this */

To display the links:

foreach($service as $key => $value) {
    if(isset($submenu[$key])) {
        echo '<li><a href="">'.$value.'</a>
        <ul>';
        foreach($submenu as $keysub => $valuesub) {
            echo '<li><a href="">'.$valuesub.'</a></li>';
        }
        echo '</ul></li>';
    }
    else {
        echo '<li><a href="">'.$value.'</a></li>';
    }
}

This displays me all the menu correctly, except for the very first of all the submenu (just the first one).

<li>
    <a href="">Servicios</a>
        <ul>
            <li>
                <a href="">Anternational sending</a>
            </li>
            <li>
                <a href="">Parking service</a>
            </li>
            <!-- and others -->
        </ul>
    </a>
</li>

As you can see, there is an "A" instead of and "I". I tried other words, like "Envíos internacionales" (in spanish), and outputs "�nvíos internacionales".

I really don't know why it's doing this.

Upvotes: 0

Views: 56

Answers (2)

shatheesh
shatheesh

Reputation: 633

Even though your page is in UTF8, make sure that your DB table is in UTF8 encoding (If the mentioned data is been populated from DB). You could also try using utf8_encode or iconv .

This may also happen if there exists one or more encoding types are declared in a page

Upvotes: 0

MoreThanChaos
MoreThanChaos

Reputation: 2092

Make sure all your PHP files are saved using UTF-8 without BOM (byte order mark), you can easly check what encoding is currently set and convert files using freeware notepad++. There is "Format" option in main menu, you can either set or convert currently opened file to desired encoding. You can also check for byte order mark using some generic hex editor.

Upvotes: 1

Related Questions