I'm just using a single-dimension array, nothing special
$invalid_custom_transaction_ids = array();
Method 1:
foreach($result as $row) {
if($row['TransactionID'] == $paypal_transaction_id) {
error_log("[DIE]1");
die();
}
error_log("[PUSHING]".$row['CustomTransID']);
array_push($invalid_custom_transaction_ids, $row['CustomTransID']);
}
Method 2:
foreach($result as $row) {
if($row['TransactionID'] == $paypal_transaction_id) {
error_log("[DIE]1");
die();
}
error_log("[PUSHING]".$row['CustomTransID']);
$invalid_custom_transaction_ids[] = $row['CustomTransID'];
}
The following is printed to the debug log, showing that there are values that I've tried adding to the array()
[03-Nov-2014 08:48:25 America/Los_Angeles] [PUSHING]Ux837Yn3rK3
When I try to print the array to the debug_log using the following code
error_log(var_dump($invalid_custom_transaction_ids));
it returns blank, I've also tried this
error_log(array_values($invalid_custom_transaction_ids));
Output to the error_log file looks like this:
[03-Nov-2014 08:48:25 America/Los_Angeles]
Then the following error is printed
[03-Nov-2014 08:48:25 America/Los_Angeles] PHP Warning: Invalid argument supplied for foreach() in /path/to/script.php on line 195
The code that is on line 195 is as follow:
function uniqueTransactionCheck() {
error_log("[UTC]1");
error_log(var_dump($invalid_custom_transaction_ids));
error_log("Is array: " . is_array($invalid_custom_transaction_ids));
foreach($invalid_custom_transaction_ids as $invalid) {
if($custom_transaction_id == $invalid) {
$custom_transaction_id = generateTransactionID();
uniqueTransactionCheck();
}
}
}
What's the deal? I don't understand this at all, I've been trying and trying to get this right, and shuffling through different documentaries and methods. I'm absolutely flabbergasted.
-snip-
$invalid_custom_transactions_idsis empty, and therefor theforeach()will throw that error... Try tovar_dump()it anddie()to see if you have something in it for sure...