Jump to content

how to check if only one value in an array is missing?


gibigbig

Recommended Posts

Not sure axactly what you want as your explanation is a bit lacking. in your subject you mention an array. in your post text you only mention variables. So maybe...

$a=array(a,b,c,d,e,f,g,h,i,j);
$b=array(a,b,c,z);//drop the z to see ~found~
$y=array_intersect($a,$b);
$z=array_diff($b,$y);
if(count($z)==0)
echo "found";
else
echo "not found";

 

 

HTH

Teamatomic

maybe this will do

 

if ( (isset($a)) && (isset($b)) && (isset($c)) && (isset($d)) ) {
// your code here

 

does not work

Not sure axactly what you want as your explanation is a bit lacking. in your subject you mention an array. in your post text you only mention variables. So maybe...

$a=array(a,b,c,d,e,f,g,h,i,j);
$b=array(a,b,c,z);//drop the z to see ~found~
$y=array_intersect($a,$b);
$z=array_diff($b,$y);
if(count($z)==0)
echo "found";
else
echo "not found";

 

 

HTH

Teamatomic

ok i have four variables and i want a query to execute ONLY if ALL four variables have something stored in them.

this is my code so far:

if ( (isset($newinfo)) && (isset($gibid)) && (isset($type)) && (isset($full_type)) ) {

$query1 = "UPDATE formresults SET sdata = '".$newinfo."' WHERE userid = ".$gibid." AND fid='".$fid."' And title = '".$full_type."'";
mysql_query($query1);

echo "<html><body><meta http-equiv='refresh' content='2;url=####url here#####p'>Edited sucessfully for user ".$gibid." on form ".$fid." with the title ".$full_type." and the message is<p>".$newinfo."</p></body></html>";
} else {echo "not allowed"; };

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.