title: When I use base64_decode why it return at the end characters like ÃÜ or 7? they are wrong
body: <p>When I am encrypting in base64 the encripted value is right and I can see normal values of the results i want, The problems appears when I use the function to decode base64 (base64_decode).</p>
  
  <p>In the results appears , at the end, the characters like ÃÜ or 7. I set  two cases and all code I am using</p>
  
  <p>Could you help me please? I send you all the code implied in the pages...</p>
  
  <p>==================================================================================</p>
  
  <h2>CASE 1:</h2>
  
  <h3>String:</h3>
  
  <pre><code>CIF_NIF::multiline++++1--2++aaaa--bbbbbb
  </code></pre>
  
  <h3>base64_encoded:</h3>
  
  <pre><code>Q0lGX05JRjo6bXVsdGlsaW5lKysrKzEtLTIrK2FhYWEtLWJiYmJiYg==
  </code></pre>
  
  <h3>base64_decoded:</h3>
  
  <pre><code>CIF_NIF::multiline++++1--2++aaaa--bbbbbb ÃÜ
  </code></pre>
  
  <p>==================================================================================</p>
  
  <h2>CASE 2:</h2>
  
  <h3>String:</h3>
  
  <pre><code>VALOR::varchar++bool
  </code></pre>
  
  <h3>base64_encoded:</h3>
  
  <pre><code>VkFMT1I6OnZhcmNoYXIrK2Jvb2w=
  </code></pre>
  
  <h3>base64_decoded:</h3>
  
  <pre><code>VALOR::varchar++bool7
  </code></pre>
  
  <p>==================================================================================</p>
  
  <h2>AJAX CALL:</h2>
  
  <pre><code>$.ajax({
      url: _ajax_url,
      type: "GET",
      async: true,
      data: {
          info: data
      },
      contentType: "application/json; charset=utf-8",
  
      //dataType: "jsonp",
      success: function (data, textStatus) {....
      }
  });
  </code></pre>
  
  <p>==================================================================================</p>
  
  <h2>PHP CODE:</h2>
  
  <h3>encoding function ...</h3>
  
  <pre><code>return base64_encode($res);
  </code></pre>
  
  <p>when I echo de return in the explorer the results are the values I set before.</p>
  
  <h3>dencoding function ...</h3>
  
  <pre><code>return base64_encode($res);
  </code></pre>
  
  <p>when I echo de return in the explorer the results are the values I set before.</p>
  
  <h3>$string_b64 is thje coded in base64 value, you can se the real values before...</h3>
  
  <pre><code>$string =  base64_decode($string_b64);
  </code></pre>
  
  <p>==================================================================================
  I add you the headers of my php page:</p>
  
  <pre><code>header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
  header("Pragma: no-cache"); //HTTP 1.0
  header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  header('Content-Type: text/html; charset=ISO-8859-1');
  </code></pre>
  
  <h1>I don't know if it can implies a rare behavior in base64_de code.</h1>
  
  <p>the function code are:</p>
  
  <pre><code>public static function encrypting($array) {
      $res = "";
      $delimiter = array("||", "::", "++", "--");
  
      if (is_array($array)) {
  
          $gen = "";
          //echo implode("&gt;", $array[0]);
          //echo count($array);
          foreach($array as $clave = &gt; $valor) {
              $aux = [];
              if ($gen != "") $gen. = $delimiter[0];
  
              foreach($valor as $v) {
                  if (is_array($v)) {
                      array_push($aux, implode($delimiter[3], $v));
                  } else {
                      array_push($aux, $v);
                  }
              }
  
              $gen = "$clave$delimiter[1]".implode($delimiter[2], $aux);
  
          }
  
          $res = $gen;
      } else $res = $array;
  
      return base64_encode($res);
      //return $res;
  }
  
  
  public static function decrypting($string_b64) {
      $res = [];
  
      $string = imap_base64($string_b64);
  
      echo $string;
  
      $delimiter = array("||", "::", "++", "--");
  
      $pas1 = explode($delimiter[0], $string);
  
      foreach($pas1 as $valor1) {
          $i = 0;
  
          $pas2 = explode($delimiter[1], $valor1);
  
          $aux = [];
  
          $pas3 = explode($delimiter[2], $pas2[1]);
  
          foreach($pas3 as $valor2) {
  
              if (strpos($valor2, $delimiter[3]) &gt; 0) $aux[] = explode($delimiter[3], $valor2);
              else $aux[] = trim($valor2);
  
          }
  
          $res[$pas2[0]] = $aux;
      }
  
      return $res;
  }
  </code></pre>
  
  <p>==================================================================================
  EXAMPLE OF USE:</p>
  
  <pre><code>$personalitzats1 = array("CIF_NIF" =&gt; array(false, "", "Aquest Camp es personalitzat...."));
  
  $value = encrypting($personalitzats1)
  
  decrypting($value);
  </code></pre>
  
  <p>The problem is in decrypting I echo the value after base64_decode and it is when the characters appear.</p>
  
  <p>I have saved the page as <strong>ISO</strong>: <strong>cp1252</strong> codification (the standard) I don't think so iti s the problem.</p>
  
  <p>If I use an external web page like <a href="http://www.opinionatedgeek.com/dotnet/tools/base64decode/" rel="nofollow">http://www.opinionatedgeek.com/dotnet/tools/base64decode/</a> and I set in the textarea the value Q0lGX05JRjo6bXVsdGlsaW5lKysrKzEtLTIrK2FhYWEtLWJiYmJiYg== the result is the correct.</p>