I'm trying to clean an array from empty values by using the following function:
function remove_empty_cells($data)
{
$findthis = array("/\r\n/u", "/\n/u", "/\r/u", "/\s+/u", "~\x{00a0}~");
for($i=0; $i<count($data); $i++)
{
$data[$i] = preg_replace($findthis, " ", $data[$i]);
$data[$i] = htmlspecialchars_decode(htmlspecialchars($data[$i], ENT_SUBSTITUTE, 'UTF-8'));
if (empty($data[$i]) ||
mb_strlen($data[$i]) < strlen($data[$i]) ||
is_null($data[$i]) ||
$data[$i] = " " ||
$data[$i] = "" ||
$data[$i] == "0")
{
array_splice($data, $i, 1);
};//end if
};//end for
return $data;
};//end func
The empty values don't go away, I fail to identify them..
the data:
array (
0 => '
',
1 => 'BEGIN:VCARD
',
2 => '
',
3 => '
',
4 => '
',
5 => '
',
6 => '
',
7 => 'VERSION:2.1
',
... might be some encoding problem or something.. it doesnt look like multibyte characters.. the result i get is:
array (
0 => 'BEGIN:VCARD
',
1 => '
',
2 => '
',
3 => 'VERSION:2.1
',
...
\x{00a0}
get a unicode flag too?