I have tried both these methods to remove the 0 values from this array but to no avail
foreach ($matches as $array_key=>$array_item)
{
if($matches[$array_key] == 0)
{
unset($matches[$array_key]);
}
}
var_dump ($matches[$array_key]);
and this
$matches_without_nulls = array_filter($matches);
print_r($matches_without_nulls[1]);
However, the string I keep getting is this
{ [0] => string(7) "2337667" [1] => string(7) "2335765" [2] => string(7) "2332651" [3] => string(7) "2328582" [4] => string(1) "0" [5] => string(1) "0" [6] => string(1) "0" [7] => string(1) "0" }
Any idea on what is happening?
Your array does not contains
0(integer), it contains"0"(string):That will do the trick.
PS: Why are you printing out a none-existing value
$matches[$array_key]? It has been unset, soNULLis provided. Test your code withvar_dump ($matches);.I just tried this and it works just fine: