为Foreach提供的Ajax无效参数()

I have this problem, but all of the rest function after this code is execute normally.

the problem in console log show as "Invalid Argument Supplied For Foreach() Line 170"

{"readyState":4,"responseText":"
Warning: Invalid argument supplied for foreach() in /home/public_html/fetch.php on line 170
Warning: Invalid argument supplied for foreach() in /home/public_html/fetch.php on line 170
Warning: Invalid argument supplied for foreach() in /home/public_html/fetch.php on line 170 {\"status\":\"1\",\"text\":\" <\/i> Payment Success. Please wait...\"}","status":200,"statusText":"parsererror"}

I'm using ajax to load this page.php with code

$passphrases = [ strToHex('alpha1'), strToHex('alpha1alpha2'), strToHex('alpha1alpha2alpha3'), strToHex('alpha1alpha2alpha3alpha4') ];
$keys = [ $block_io->initKey()->fromPassphrase($passphrases[0]), $block_io->initKey()->fromPassphrase($passphrases[1]), $block_io->initKey()->fromPassphrase($passphrases[2]), $block_io->initKey()->fromPassphrase($passphrases[3]) ];

$pubKeyStr = $keys[0]->getPublicKey() . "," . $keys[1]->getPublicKey() . "," . $keys[2]->getPublicKey() . "," . $keys[3]->getPublicKey();


foreach ($keys as &$key) {
    foreach ($getWd['data']['inputs'] as &$input) {
        // iterate over all the inputs

        $dataToSign = $input['data_to_sign']; 
        foreach ($input['signers'] as &$signer) {
            // iterate over all the signers for this input
            // find the key that can sign for the signer_public_key
            if ($key->getPublicKey() == $signer['signer_public_key'])
            { // we found the key, let's sign the data

              $signer['signed_data'] = $key->signHash($dataToSign);
            }
        }
    }
    // all the data's signed for this public key, let's give it to Block.io
    $json_string = json_encode($getWd['data']);

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'https://block.io/api/v2/sign_transaction/?api_key='.$apiKey.'&signature_data='.$json_string.'');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, ''.SITENAME.' API PURCHASE');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
$r1 = json_decode($query, true);

    $counter += 1; 

    if ($counter == 3) { break; }
}

after that code is I update database and send email to my member. If i try this code in xampp localhost, it works perfect without any error in console.log, but after I upload to my hosting. It gives me error like that

any one know how to fix this? please help

I dont why you are using "as &$key" and "as &$input" in foreach brackets

Instead of that use "as $key" and "as $input" in foreach brackets

just like (remove & symbol):

foreach ($keys as $key) {
    foreach ($getWd['data']['inputs'] as $input) {
      ....
      ....
    }
}

and try..