0) { $rechtsformen = $_POST['rechtsform']; } else { $legalFormArray = json_decode(sendAPILegalFormRequest($username, $password), true); foreach ($legalFormArray as $rechtsform) { $rechtsformen[] = $rechtsform["id"]; } } $sitze = array(); if (isset($_POST['sitze']) && is_array($_POST['sitze']) && count($_POST['sitze']) > 0) { $sitze = $_POST['sitze']; } else { $communityArray = json_decode(sendAPICommunityRequest($username, $password), true); foreach ($communityArray as $community) { $sitze[] = $community["bfsId"]; } } $requests_to_do = Array(); // Loop through the selected values foreach ($rechtsformen as $rechtsform) { $data["legalFormId"] = $rechtsform; // Loop through the selected values foreach ($sitze as $sitz) { $data["legalSeatId"] = $sitz; //$response = sendAPICompanySearchRequest($username, $password, $data); $requests_to_do[] = $data; } } $taskdata = Array(); $taskdata['requests'] = $requests_to_do; $taskdata['email'] = 'roman.schenk37@gmail.com'; $taskString = json_encode($taskdata); $taskfilename = 'tasks/'.time().'-'.bin2hex(random_bytes(4)).'.txt'; $taskfile = fopen($taskfilename, 'w'); if($taskfile){ echo "writing to file"; fwrite($taskfile, $taskString); fclose($taskfile); } else { echo "not writing to file"; } //$constructed_response = $response; // Send the response back to the client //header('Content-Type: application/json'); //echo $constructed_response; ?>