I notice that in your "recursive" part of the function, you don't catch the result of your "checkother" call. So if you have a straight up recursive array, you won't return anything unless there are sub-elements.
Okay, now, your function seems a little off to me. Basically, you have a multi-level array in your first index. So if you walk through your function, you take that first array (array("cardtype")) and send it as the value to your function. So during this loop there is no other data in the array, no sub-array, so it goes to the else{} statement. Here we see that there is no array key in your array (except for the numerical "0" for the first index). So it should be returning false from the internal function (which you don't capture).
I'm not 100% sure how to really "fix" this problem. I'd have to say that if I were to try something like this, I'd do the following:
function checkOther($array, $recursive=0)
{
$elementarr = null;
$type = null;
if(empty($recursive) || is_null($recursive))
$elementarr = $array;
$arrTxtFields = array(
'cheq'=>array('cheqno', 'cheqamt'),
'cardtype'=>array('cardno', 'expirydate'),
'purchorderno'=>array('orderno'),
'invoice'=>array('attn'),
);
// Check the structure of the $array
foreach($array as $key=>$value)
{
if(!array_key_exists($value, $arrTxtFields))
$type = $value;
else
{
if(is_null($type) && !array_key_exists($value, $arrTxtFields))
return false;
if(in_array($value, $arrTxtFields[$type]))
continue;
else
return false;
}
}
// If we're here, return false because it's an empty array or missing elements
return false;
}
Now, it seems that you're trying to print out boolean values. Booleans don't really print out, so you'd have to use [man]print_r/man or [man]var_dump[/man] to see them; or, you can cast them as a string or even use a ternary operator to print out "true" or "false":
echo '$bln is ' . ($bln ? 'true' : 'false');
Also, since it's a predefined structure, it may be easier to loop over your pre-determined array $arrTxtFields rather than loop over the user's input. Might even go faster since you'd be searching for what you need, not for everything.