N
N
Nikolay Matyushkin2018-01-21 21:38:47
PHP
Nikolay Matyushkin, 2018-01-21 21:38:47

Encoding data from an array, what's wrong?

In general. There is a root index.php file into which the menu is loaded using such an array

$menu = [
    ["link"=>"Главная", "href"=>"index.php"],
    ["link"=>"О себе", "href"=>"about_me.php"],
    ["link"=>"Путешествия", "href"=>"travel.php"],
    ["link"=>"Мои песни", "href"=>"my_music.php"],
    ["link"=>"Видеозаписи", "href"=>"my_video.php"],
  ];

and features
function drawMenu($menu, $poz = true){
    global $menu;
    if(!is_array($menu)){
      return false;
    }
    $sort_by = " ";
      if($poz == false){
        $sort_by = "style ='display: block';";
      }
        echo "<ul>";
      foreach($menu as $item){
      echo "<li $sort_by>";
        echo "<a href={$item['href']}>{$item['link']}</a>";
      echo "</li>";
      }
        echo "</ul>";
  }

The menu is displayed in the form of rhombuses with question marks inside. If you place an array in index, everything works and the menu is displayed correctly, but this implementation does not suit me. The array and function are in a separate file, one level above the root index. In .htaccess I wrote AddDefaultCharset UTF-8 does not help. Tell me what can be done?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel, 2018-01-21
@Vidgar

I once had the same problem. Until I switched to a normal editor. Check the encoding in the function file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question