【发布时间】:2017-07-28 22:14:52
【问题描述】:
我正在尝试从 MS-SQL 查询中获取一个包含 utf-8 值的数组。
几乎一切正常,除了结果数组如下所示:
Array (
[id] => 1;
[0] => 1; // this is redundant
[countryName] => england;
[1] => england; // this is redundant
)
我不想要重复的数字键。为什么它们甚至被创造出来?导致此结果的代码是:
# execute the query
foreach ($pdoConnection->query($sqlStatement) as $row) {
// encode row in utf8 so json works and save row in array
$output[] = array_map('utf8_encode', $row);
}
感谢您知道如何解决这个问题。
【问题讨论】:
-
尝试
var_dump行,看看里面有什么
标签: php arrays sql-server json pdo