Warning on my site

I am getting this error /warning on my site.
Warning: count(): Parameter must be an array or an object that implements Countable

The line of code is below

$nfield = $_POST[nfield];
    if (count($nfield) > 0)
    {
        foreach ($nfield as $key => $var)
        {
            $var = check_html($var, "nohtml");
            $var = trim(htmlspecialchars($var, ENT_QUOTES));
            $nfield[$key] = $var;
        }
    }

Please, how can i fix this, it kills registration on my site.

could be that $nfield is not an array. Count is counting how many items are in an array.
If $_POST[‘nfield’] is an array you should do:

if (is_array($nfield) && count($nfield) > 0) {
    //your code
}

if $nfield is a number, you should change like this:

$nfield = intval($_POST['nfield']));
if ($nfield > 0) {
    //your code
}

BE CAREFUL that $_POST[nfield] is wrong, should be: $_POST[‘nfield’]