函数split()已弃用并已分解..未定义的偏移量:文件中出现1 E_NOTICE错误


function split() deprecated and explode ....Undefined offset: 1 E_NOTICE Error in file

我收到这个错误:function split() deprecated

list ($kk, $vv) = split( '  ', $buf, 2);

当我用explodepreg_split替换它时,我得到了这个错误Undefined offset: 1 E_NOTICE Error in file

list ($kk, $vv) = explode( "  ", $buf, 2);

这是完整的代码

function get_toprotatingbanners()
{
    $s = array ();
    $file = fopen ('inc/adsadmin/toprotatingbanners.php', 'r');
    if ($file)
    {
        while ($buf = fgets ($file, 20000))
        {
            $buf = chop ($buf);
            if (($buf != '<?/*' AND $buf != '*/?>'))
            {
                list ($kk, $vv) = explode(" ", $buf, 2);
                $s[$kk] = $vv;
                continue;
            }
        }
    }
    fclose ($file);
    return $s;
}

请帮帮我。

函数拆分已被弃用"此函数在PHP 5.3.0中被弃用,在PHP 7.0.0中被删除。"如您在PHP.net/manual/en/Function.split.PHP 上看到的

未定义的偏移量:1是因为$buf未定义。

警告这个函数在PHP 5.3.0中被弃用,在PHP 7.0.0中被删除。

该功能的替代方案包括:

preg_split()
explode()
str_split()