我验证了一个二维数组,当验证器失败时,validator->errors()
包含:
MessageBag {#1010 ▼
#messages: array:8 [▼
"1.0" => array:1 [▼
0 => "The 1.0 does not match the format d/m/Y."
]
"2.0" => array:1 [▶]
"1.1" => array:1 [▶]
"2.1" => array:1 [▶]
"1.2" => array:1 [▶]
"2.2" => array:1 [▶]
"1.4" => array:1 [▶]
"2.4" => array:1 [▶]
]
#format: ":message"
}
现在我可以访问所有这样的错误:
foreach ($errors->all() as $error) {
}
这会将消息放入$error = "The 1.0 does not match the format d/m/Y.";
如何访问“1.0”键?