Error Call to Undefined Function split()

Asked

Viewed 3,221 times

4

Everything in my code appears to be correct however the error: "Call to Undefined Function split()" is presented to me on the screen when running my script so I saw the error is on line 31 how can I fix it ?

if(isset($_POST['lista']) && $_POST['delimitador'])
{
    separar(trim($_POST['lista']), $_POST['delimitador']);
}
function separar($lista, $delimitador){
$ab = split("\n", $lista); //está é a linha 31 aonde o erro e apresentado
$cb = count($ab);
for($x = 0; $x < $cb; $x++){
    list($card, $mes, $ano, $cvv) = split("\\".$delimitador, $ab[$x]);
    testar($card, $mes, $ano, $cvv);
    flush();
    ob_flush();
}
}
function getStr($string,$start,$end){
    $str = explode($start,$string);
    $str = explode($end,$str[1]);
    return $str[0];
}
  • try to give an escape character do so n

  • 4

    Change split to str_split. According to the split documentation: This function is OBSOLETE in PHP 5.3.0 and has been REMOVED in PHP 7.0.0. Alternatives to this function include: preg_split(), explode(), str_split()

  • ha yes, thanks for the friendly info I will try.

1 answer

6


The function split() was removed from php7. The closest is explode() or preg_split().

Change lines:

$ab = split("\n", $lista);
list($card, $mes, $ano, $cvv) = split("\\".$delimitador, $ab[$x]);

To:

$ab = explode("\n", $lista);
list($card, $mes, $ano, $cvv) = explode("\\".$delimitador, $ab[$x]);
  • old error missing a new and presented Can’t use Function Return value in write context

  • @Brunolazarine on which line happens?

  • Line 34 list($card, $month, $year, $cvv) = explode(" ". $delimiter, $ab[$x]);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.