在PHP中,我将区域设置如下:
// I simplified code, actually there exists 20 different locales and system selects proper language
$myArray=array('de_DE.utf8', 'de_DE' );
$localeData = "'" . implode("', '", $myArray) . "'";
// $localeData = "'de_DE.utf8', 'de_DE'"
setlocale(LC_TIME, $localeData);这件事一直在进行到现在。经过几个小时的调试,我发现这是可行的:
setlocale(LC_TIME, 'de_DE.utf8', 'de_DE');setlocale的行为改变了吗?
将地区设置为长字符串比较容易。
但是现在我该怎么做setlocale呢?
我需要将每个值作为参数传递给setlocale?
(我在Apache 2和Centos 6.5中使用了PHP 5.4.30 )
发布于 2014-08-12 21:15:28
可以使用以下代码将每个值获取到单独的变量。
$myArray = array('de_DE.utf8', 'de_DE' );
list($a, $b) = $myArray;
echo $a; //de_DE.utf8
echo $b; //de_DE现在你可以这样做了
setlocale(LC_TIME, $a, $b);
而且,应该可以像这样将数组直接传递到setlocale。
setlocale(LC_TIME, $myArray);
http://php.net/manual/en/function.setlocale.php
https://stackoverflow.com/questions/25274026
复制相似问题