我有一个数组,如下所示。我想回显一个特定的值。现在我正在做的是:
$array[0]->Question
所以,它输出: Question1
但我不想要这个解决方案。
有没有办法在没有键的情况下回显特定值,例如(它不是解决方案):
$array[]->Field == 'Field1' ? $array[]->Question : '';
请提出解决方案。
谢谢!
[Required] => Array
(
[0] => stdClass Object
(
[Field] => Field1
[Question] => Question1
[DataType] => Boolean
)
[1] => stdClass Object
(
[Field] => Field2
[Question] => Question2
[DataType] => varchar
)
[2] => stdClass Object
(
[Field] => Field3
[Question] => Question3
[DataType] => Boolean
)
[3] => stdClass Object
(
[Field] => Field4
[Question] => Question5
[DataType] => Int
)
)