jeudi 19 décembre 2019

IF statement not working inside a function [duplicate]

I am trying to create a slug URL function, if condition not working inside the function

Mycode

function slug($text) {
    $reslt = mysqli_query($connection, "SELECT slug FROM users WHERE slug='".$text."'");
    $data = mysqli_fetch_array($reslt);

    if (isset($text)) {
        if (in_array($text, $data)) {
            $count = 0;
            while (in_array(($text . '-' . ++$count), $data));
            $text = $text . '-' . $count;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire