我試圖檢查是否有嵌套數組中的空數組。如何檢查多維數組是否爲空或laravel
這是我從我的表單中得到的。
array:15 [▼
"_token" => "h4aR4xJlWhZveRKbAgHzgzHWSKSqyhVKb7OHAgWH"
"name" => "Test office"
"is_department" => "0"
"hours" => "1-3"
"description" => "Description"
"content" => "<p>Content</p>"
"street" => "123 Street"
"city" => "Foomania"
"state" => "Sweet state"
"postal" => "98234"
"phone" => "5748293212"
"fax" => "2123131233"
"email" => "[email protected]"
"additional-page" => ""
"office_fees" => array:4 [▼
0 => array:2 [▼
"description" => ""
"fee" => ""
]
1 => array:2 [▼
"description" => ""
"fee" => ""
]
2 => array:2 [▼
"description" => ""
"fee" => ""
]
3 => array:2 [▼
"description" => ""
"fee" => ""
]
]
]
如何檢查office_fees
中是否有空數組?
要明確,office_fees
將始終返回至少一個數組。我想要的是能夠確定office_fees
是否需要保存到另一個模型。
我試圖與'''array_collapse'''使多維數組爲單一陣列,並檢查我的關鍵是空的。我想,這可能是獲得我想要的解決方案。 – Nomadme