[Solved] Wrong output in php program


Side note, this is bad code:

in_array(isset($weekendArr) && $weekendArr,$arr)

do it like

isset($weekendArr) && in_array($weekendArr,$arr)

and in_array is not strict so this

in_array(true,array('w','s'))

will be allways TRUE

do it with:

in_array(true,array('w','s'),true)

and you see.

And you can’t check an array with an array the $needle be an STRING here.
The only solution is to do splitt your STRING into two values and then check two times for TRUE

$c="Sunday,Monday";
foreach(explode(',',$c) as $check){
  if(in_array($c,$arr,true))
  {
    echo $check.' is in array';
  }
  else 
  {
    echo $check.' is NOT in array';
  }
}

Hope that helps a little.

solved Wrong output in php program