我得到一個類似於下列數組的數組。如何在PHP中用鍵刪除空數組值?
{"form_data":["1","2","4","5","","6"],"final_data":["1","2","4","5","","6"]}
如果表單數據值null
,我想下一個鍵的值來代替該鍵的值。 像上面那樣,在值5之後,我有空值。它需要是這樣的:
"final_data":["1","2","4","5","fill this with 6","remove this"]
"final_data":["1","2","4","5","6"] like this
我試過array_filter()
,但它沒有幫助。
輸出'的array_flter'功能 –
可能重複[刪除空數組元件](HT tps://stackoverflow.com/questions/3654295/remove-empty-array-elements) – Script47