I have a vector in which I try to eliminate the spaces that are empty in their entirety, something like this:
array[0][0:"6371", 1:"2016-05-31", 2:"Juan Jose Mendoza"];
array[1][0:"", 1:"", 2:""];
array[2][0:"6372", 1:"2016-05-31", 2:"Andrea Marcela Pena"];
what I am looking for is the way to eliminate the empty line and re-arrange the vector in a simple way (without the need to go through it or something like that) either in php or javascript the final result would be something like this:
array[0][0:"6371", 1:"2016-05-31", 2:"Juan Jose Mendoza"];
array[1][0:"6372", 1:"2016-05-31", 2:"Andrea Marcela Pena"];
where the position array[1][0:"", 1:"", 2:""];
, having all its fields empty, will be removed and we will rearrange the vector.
If I understand correctly, you have a
Array
containingObjetos
, "Array-like Objects
" and you want to filter that array by removing positions whose objects are completely empty. You can use the following code:Here I leave an alternative without traversing the entire array. The idea is as follows: convert the array to a string, remove the empty elements, convert the string back to an array.
The code could be like this: