I have an array that holds variables
<?php
include_once '../Includes/Secure.php';
include_once '../Includes/ConnectionInfo.php';
/*Acquiring the security class*/
$mSecure = new IncludesSecure;
$mConnectionInfo = new IncludesConnectionInfo();
$mConnectionInfo->GetConnection();
$email ="sule@gmail.com";
if ($mConnectionInfo->conn){
echo "is connected <br/>";
$stmt2 = $mConnectionInfo->conn->prepare('SELECT email, secret_key, secret_iv FROM users');
$work2 = $stmt2->execute();
$returnedvalue = array();
if ($work2){
while($row = $stmt2->fetch(PDO::FETCH_ASSOC)){
$secret_key = $row['secret_key'];
$secret_iv = $row['secret_iv'];
$secret_key = $mSecure->my_simple_crypt_key($row['secret_key'],'d','sha384');//encrypt with sha384
$secret_iv = $mSecure->my_simple_crypt_key($row['secret_iv'],'d','sha384');//encrypt with sha384
$decryptedemail = $mSecure->my_simple_crypt($row['email'],'d','sha384',$secret_key,$secret_iv);//encrypt with sha384
$value = ["Email" => $decryptedemail];
array_push($returnedvalue, $value);
}
echo json_encode($returnedvalue);
echo "<br/>";
echo $email;
if(in_array($email,$returnedvalue,TRUE)){
echo "<br/> value exists";
}
else{
echo "<br/> value doesnt exists<br/>";
}
}
}
?>
below is the output
is connected
[{"Email":"alsongdunstan2@gmail.com"},{"Email":"sule@gmail.com"}]
sule@gmail.com
value doesnt exists
it shows that sule@gmail.com is in the array but when i check if it exists it shows that value doesnt exist.
need some help on how to check whether sule@gmail.com exists in array $returnedvalue
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…