[FX.php List] in_array code fragment

David Ness dness at bondedbuilders.com
Fri Sep 15 12:33:40 MDT 2006


Dan,

Thanks for the response, and the 'push' ;-)

The following code works, though I would think there might be a single
PHP function for either accessing the
$referenceNumber_array['data'][0]['referenceNumber'] array directly, or
by assigning the values in this nested array to another (non-nested)
array variable without using a 'foreach', perhaps using the PHP function
'array-values()'. But I guess a single foreach does the trick
adequately. Maybe it's the right way.

You're right. I don't have as complete a grasp on arrays, especially
nested arrays and their manipulation as I need to have, but I will.


Here's what I ended up with, and it appears to work fine:

// Read in all values contained in the
// referenceNumber field from FM
// Layout 'referenceNumberLayout' contains 2 fields:
// 'customer_number' & 'referenceNumber'
$Query = new FX($serverIP,$webCompanionPort);
$Query->SetDBData($databasename,'referenceNumberLayout', 'all');
$Query->SetDBPassword($password,$username);
$Query->AddDBParam('customer_number', $customerNumber, "eq" );
$QueryResult = $Query->FMFind();
foreach ($QueryResult['data'] as $key => $QueryArray ) {
	$referenceNumber_array[] = $QueryArray['reference_number'][0];
}

while (($importdata = fgetcsv($handle, 0, ",")) != FALSE) {
    // Check to see if Ref# is unique for this customer.
    // This is the mechanism for excluding duplicate submissions.
    // $importdata[0] contains the reference number
    if( in_array( $importdata[0],
$referenceNumber_array['referenceNumber'] )) {
        $validationMsg = 'Skipped';
    }
}
--
David Ness


More information about the FX.php_List mailing list