我尝试将相同的字符串添加到每个数组值。
我尝试使用array_walk()
,就像我在this answer上阅读一样。
但我明白了:注意:数组转换为字符串
我也尝试使用array_map()
,但我收到同样的错误通知。
工作代码
if ($voice->getValue() === Voice::Passive) {
array_walk($aller_form, function(&$value, $key) { $value .= ' être'; });
$aller_form = [
Mood::Indicatif => [
Tense::Futur_compose => [
Person::FirstPersonSingular => 'vais être',
Person::SecondPersonSingular => 'vas être',
Person::ThirdPersonSingular => 'va être',
Person::FirstPersonPlural => 'allons être',
Person::SecondPersonPlural => 'allez être',
Person::ThirdPersonPlural => 'vont être'
]
]
];
}
return $aller_form[$mood->getValue()][$tense->getValue()][$person->getValue()];
无法使用代码
if ($voice->getValue() === Voice::Passive) {
array_walk($aller_form, function(&$value, $key) { $value .= ' être'; });
}
return $aller_form[$mood->getValue()][$tense->getValue()][$person->getValue()];
修改
完整的错误日志:
注意:第2行的数组到字符串转换
警告:第4行非法字符串偏移'futur_compose'
警告:第4行上的非法字符串偏移'firstPersonSingular'
(我看到每个人一次这三条错误行的6次)