I’m doing some content importing using the node import module in drupal. My problem is that I’m getting errors on data that looks like it should be working smoothly. This is the code at issue:
if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) { //$allowed_values[$item['value']] == NULL) {
print "||||" . $item['value'] . "||||";
print_r($allowed_values);
And this is a sample of what is printing:
||||1||||Array ( [0] => no [1] => Zicam® Cold Remedy Nasal Gel Spray Single Hole Actuator (“Jet”) ) ||||1||||Array ( [0] => No [1] => Yes )
It looks to me like it’s saying that “1” is not in the array, when printing the way “1” is clearly visible. If I replace the existing module code with the commented out check, no error is thrown.
Your code is not complete and i cannot reproduce the error.
Allow me to adjust your example:
gives the desired output:
PHP also works when you assign the needle a string and not an integer. It is some sort of lossy type conversion that can be really convenient but also a pain in the ass. Often you dont know whats going on and errors are caused.
But still. I bet you have something wrong with your variable types.
You should dump them and see what is really in there.