here is my function:
function checkArray($color,$file) {
$color = trim($color);
$settings = getSettings($file,1);
if (in_array($color,$settings)) return true;
else return false;
}
$settings in this context is an array:
Array
(
[0] => Black
[1] => Blackpol
[2] => Blk
[3] => Blue
[4] => Bronz
[5] => Bronze
[6] => Brz
)
i have this function looping a few times with the $color parameter changing each time. sample values are "Black","Blue", etc. long story short, checkArray() should return false very few times.
however, it is returning false EVERY time and i cannot for the life of me figure out why. i tried case insensitive searches, trim, printing individual outputs and comparing the strings ("Black" vs "Black")...i am not new to php or arrays but i can't figure out why this would possibly return false. help please!
PRINT_R of $settings (right before the if statement)
Array
(
[0] => Black
[1] => Blackpol
[2] => Blk
[3] => Blue
[4] => Bronz
[5] => Bronze
[6] => Brz
[7] => Bz
[8] => Cherry
[9] => Gold
[10] => Gun
[11] => Gunmet
[12] => Gunmetal
[13] => Pol
[14] => Poly
[15] => Quentin
[16] => Rootbeer
[17] => Vis
)
VAR DUMP OF $color (right before if statement)
string(5) "Black"
var_dumpof$settingsand$colorright before theifstatement to double check variable values. You may have overlooked something.$settings. Can you dump it and show us?return in_array($color, $settings);Array ( [0] => Black [1] => Blackpol [2] => Blk [3] => Blue [4] => Bronz [5] => Bronze [6] => Brz [7] => Bz [8] => Cherry [9] => Gold [10] => Gun [11] => Gunmet [12] => Gunmetal [13] => Pol [14] => Poly [15] => Quentin [16] => Rootbeer [17] => Vis )vardump $color outputsstring(5) "Black"var_dumpof$settingsinstead of aprint_r. Looks like you don't havestrings in$settings, but another datatype.