title: How to convert this array into JSON in PHP
body: <p>I read many many many posts on this subject and I tried many solutions and I can't convert this multi-array into a JSON string. This is what I see when I <code>print_r($result)</code>:</p>
  
  <pre><code>Array ( [profiles] =&gt; 
         Array ( [0] =&gt; 
                Array ( [ID] =&gt; 00000000-0000-0000-0000-000000000001 
                        [UserName] =&gt; Administrator GU 
                        [Age] =&gt; 37 
                        [CityStateCode] =&gt; Montréal 
                        [OnlineSince] =&gt; En ligne depuis 6 heures 39 minutes 
                        [IsPaying] =&gt; true 
                        [LabelOnlineStatus] =&gt; En ligne 
                      ) 
                 [1] =&gt; 
                Array ( [ID] =&gt; ab3dd04e-5621-11e3-b448-103f0c805f5a 
                        [UserName] =&gt; Guillaume Le Genie 
                        [Age] =&gt; 68 
                        [CityStateCode] =&gt; Montréal 
                        [OnlineSince] =&gt; En ligne depuis 1 jour 9 heures 
                        [IsPaying] =&gt; true 
                        [LabelOnlineStatus] =&gt; Hors-Ligne 
                      ) 
                 [2] =&gt; 
                Array ( [ID] =&gt; 00000000-0000-0000-0000-000000000050 
                        [UserName] =&gt; Baby-dragoon 
                        [Age] =&gt; 25 
                        [CityStateCode] =&gt; Québec 
                        [OnlineSince] =&gt; En ligne depuis 5 jours 6 heures 
                        [IsPaying] =&gt; true 
                        [LabelOnlineStatus] =&gt; Hors-Ligne 
                      ) 
              )      
        )
  </code></pre>
  
  <p>I try this (with and without true parameter):</p>
  
  <pre><code>$result = json_encode($result, true);
  $error = json_last_error_msg();
  echo "[ERROR : $error]-----[$result]-----";
  </code></pre>
  
  <p>And I receive:</p>
  
  <pre><code>[ERROR : Malformed UTF-8 characters, possibly incorrectly encoded]-----[]-----
  </code></pre>
  
  <p>When I try this: </p>
  
  <pre><code>$result = json_encode(htmlspecialchars(utf8_encode($result)));
  </code></pre>
  
  <p>I receive: </p>
  
  <blockquote>
    <p>Warning: utf8_encode() expects parameter 1 to be string, array given in <b>/Applications/XAMPP/xamppfiles/htdocs/cdn/php/functionsv1.php</b> on line <b>2839</b><br /> [ERROR : No error]-----[""]-----</p>
  </blockquote>
  
  <p>When I try this: </p>
  
  <pre><code>$result = json_encode(htmlspecialchars($result));
  </code></pre>
  
  <p>I receive: </p>
  
  <blockquote>
    <p>Warning: htmlspecialchars() expects parameter 1 to be string, array given in <b>/Applications/XAMPP/xamppfiles/htdocs/cdn/php/functionsv1.php</b> on line <b>2839</b><br /> [ERROR : No error]-----[null]-----</p>
  </blockquote>
  
  <p>I'm really lost!</p>
  
  <p>N.B. You see the language is French so we have a char with accent like éèàô etc...</p>
  
  <p>The data provide from MySQL Database and database is set to: </p>
  
  <pre><code>mysql_query("SET NAMES 'utf8'");
  mysql_query('SET CHARACTER SET utf8');
  </code></pre>