Skip to content

Commit

Permalink
使用 PHP 5.3 兼容的语法
Browse files Browse the repository at this point in the history
  • Loading branch information
xjchengo committed Jan 18, 2016
1 parent 803494d commit 93e3980
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Pinyin/Pinyin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Pinyin
*/
private function __construct()
{
if (!static::$dictionary) {
if (empty(static::$dictionary)) {
$list = json_decode(file_get_contents(dirname(__DIR__).'/data/dict.php'), true);
static::appends($list);
}
Expand Down Expand Up @@ -248,12 +248,12 @@ protected function string2pinyin($string)
{
$preparedString = $this->prepare($string);
$count = mb_strlen($preparedString, static::$internalCharset);
$dictionary = [];
$dictionary = array();

$i = 0;
while ($i < $count) {
$char = mb_substr($preparedString, $i++, 1, static::$internalCharset);
$pinyinGroup = isset(self::$dictionary[$char]) ? self::$dictionary[$char] : [];
$pinyinGroup = isset(self::$dictionary[$char]) ? self::$dictionary[$char] : array();
$dictionary = array_merge($dictionary, $pinyinGroup);
}

Expand Down

0 comments on commit 93e3980

Please sign in to comment.