First use array_filter()to get rid of the nodes :
$array = array_filter($array, function($x) { return trim($x) != ' '; });
$array = array_filter($array, create_function('$x', 'return trim($x) != " ";'));
Then use array_chunk()to break the array into pieces 3:
$array = array_chunk($array, 3);
This, of course, assumes that you will always receive only tuples containing name, valueand sizein that order.
source
share