Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I received this error: function split() deprecated

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

When I replaced it with explode or preg_split I got this error Undefined offset: 1 E_NOTICE Error in file

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

This is the full code

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;
}

Please help me.

like image 947
selemo Avatar asked Feb 16 '26 22:02

selemo


1 Answers

Function split is deprecated "This function was DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0." as you can see on php.net/manual/en/function.split.php

Undefined offset: 1 is because $buf is undeffined.

like image 69
alexeevyci Avatar answered Feb 18 '26 12:02

alexeevyci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!