-2
while ($row = $checkUser->fetch_assoc()) {
        $arr = $row['username'];
}

check like this just don't work

if($arr !="john"){

}else{

}

how can I check $row['username'] contain or not string "john"?

1 Answers1

0

presumming that you are getting this $row['username'] right. then

$arr = array();

while ($row = $checkUser->fetch_assoc()) {
        $arr[] = $row['username'];
}

if(in_array("john",$arr)){
    //there is a username john in the array
}else{
    //this is no john inside the array
}     
Viscocent
  • 2,024
  • 2
  • 19
  • 26