示例#1
0
function arrayToUtf8($array = null)
{
    foreach ($array as $key => $value) {
        if (!is_array($value)) {
            $array[$key] = utf8_encode($value);
        } else {
            $array[$key] = arrayToUtf8($value);
        }
    }
    return $array;
}
 /**
  * 
  * @url POST /?settings
  */
 function updateSettings($data)
 {
     //check if new logo is submitted
     if (isset($_FILES['file'])) {
         $file = $_FILES['file'];
         try {
             uploadFile($file['tmp_name'], DIR_LOGO_FILE, $file['name']);
         } catch (Exception $e) {
             throw new RestException(400, $e->getMessage());
             return;
         }
         $_POST['logo'] = DIR_LOGO_FILE . '/' . $file['name'];
         $db = new SettingsDatabase();
         $result = $db->updateSettings($_POST);
         return arrayToUtf8($result);
     }
     $db = new SettingsDatabase();
     $result = $db->updateSettings($data);
     return arrayToUtf8($result);
 }
示例#3
0
 public function arrayToUtf8($dados)
 {
     if (!empty($dados)) {
         foreach ((array) $dados as $key => $value) {
             if (is_array($value)) {
                 $dados[$key] = arrayToUtf8($value);
                 //Recursividade é legal pq recursividade é legal
             } else {
                 $dados[$key] = utf8_encode($value);
             }
         }
     }
     return $dados;
 }