I need to check if in my array that come from database (SQLSERVER, so odbc) I have a some values.
I have this code:
$dbhandle = odbc_connect("Driver={SQL Server Native Client 11.0};Server=$myServer;Database=$myDB;", $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");
$query = "SELECT NumNation, NumPlayers FROM table1";
$result = odbc_exec($dbhandle, $query);
while($rows = odbc_fetch_array($result)){
$myArray[] = $rows['NumNation']."=>".$rows['NumPlayers']; //this
Or I can have also this:
$myArray[] = $rows; //or this
} // close while
echo ("<br>".implode(",<br>",$myArray).".<br>");
Then I have some other code for select from another database tables and then I want to check if in my array (from the first table) I have this data or not.
I wrote this for example:
$NumNation = '123'
$Players = '456'
if (in_array($NumNation."=>".$NumPlayers, $myArray)) continue;
and the continue with my code for save and something else.
But the check doesn't work.
Why?
If I var_dump myArray I have this:
array(363) { [0]=> string(31) " =>2000-12-31 00:00:00" [1]=> string(31) " =>2000-12-31 00:00:00" [2]=> string(31) " =>2000-12-31 00:00:00" [3]=> string(36) " 15=>2001-02-28 00:00:00" [4]=> string(36) " 18=>2001-02-28 00:00:00" [5]=> string(36) " 18=>2001-02-28 00:00:00" [6]=> string(36) " 14=>2001-02-15 00:00:00" [7]=> string(36) " 12=>2001-02-10 00:00:00" ....so on until......[347]=> string(31) " 4 =>2013-07-23 00:00:00" [348]=> string(31) " 5 =>2013-07-23 00:00:00" [349]=> string(2) "=>" [350]=> string(36) " 011013=>2013-10-01 00:00:00" [351]=> string(36) " 011013=>2013-10-01 00:00:00" [352]=> string(36) " 011213=>2013-12-01 00:00:00" [353]=> string(36) " 011213=>2013-12-01 00:00:00" [354]=> string(36) " 0112131=>2013-12-01 00:00:00" [355]=> string(36) " 0112131=>2013-12-01 00:00:00" [356]=> string(36) " 100=>2014-11-30 00:00:00" [357]=> string(31) " 1 =>2014-12-02 00:00:00" [358]=> string(31) " 1 =>2014-12-02 00:00:00" [359]=> string(31) " 1 =>2014-12-02 00:00:00" [360]=> string(26) "00032=>2014-02-12 00:00:00" [361]=> string(26) "00032=>2014-02-12 00:00:00" [362]=> string(26) "00017=>2014-02-12 00:00:00" }