You can use array_filter() and array_map() to remove all empty and null value or array by using this logic
Data:
The data contain empty value, null value, 0 value, or empty array element.
$records = [
[
2567317.0,"123123Z23",3752.0,"OOO qwasww","446691087", "M3F23O00431","860030362370389282",321229.63,"20230116","sdfsdf",2501217.0,0.0456
],
[
"","","","",""
],
[]
];
Logic:
The Logic is array_filler() function and array_map() function remove all unless element or array from data.
$data = array_filter(array_map(function ($record) {
return array_filter(array_filter($record, function ($value) {
return $value !== null || $value === 0.0 || $value === "0";
}));
}, $records));
$data = array_filter($data);
print_r($data);
How work:
$value !== null || $value === 0.0 || $value === "0"
the logic keep 0,"0" elements and remove '' or null elements
$data = array_filter($data);
the logic remove empty arrays.
unset()on 13th element of your array.$postArr = array_map('array_filter', $postArr); $postArr = array_filter( $postArr );