PHP - 尝试从数组中获取值(api输出) - 循环难度

I found my difficulty (sorry, I'm no php coder but learning by doing ;) ) in the first piece code the loop is started. It pulls all the correct data and fills in the correct fields in a table. during this loop I need to pull per line in the table extra data by php call to an api.

This is where I re-use the InvoiceCode in the second piece of code. this gives also all the correct data in the array $response . From what i understand is that I should start here a second loop, which loops thru the array $response and fills in the $row['PaymentURL'] but this ends up in an error 500

I pull data out of a db with php script and put it in some tables

echo "</table><br><th> outstanding invoices</th> <br>";
$result = mysqli_query($con,"SELECT SOME_QUERY ");
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Username'] . "</td>";
echo "<td>" . $row['CompanyName'] . "</td>";
echo "<td>" . $row['InvoiceCode'] . "</td>";
echo "<td>" . $row['SentDate'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "<td>" . $row['AmountIncl'] . "</td>";
echo "<td>" . $row['AmountPaid'] . "</td>";

I reuse $row['InvoiceCode'] to get some api data which is not in a db field.

$api = new API();
$invoiceParams = array(
            'InvoiceCode'   => $row['InvoiceCode']);
$response = $api->sendRequest('invoice', 'show', $invoiceParams);
print_r_pre($response);

In the output of $response there is output of PaymentURL. This I wish to capture in separate table

Example output

[invoice] => Array ( [Identifier] => 17 [InvoiceCode] => F0005 [Debtor] => 14 [DebtorCode] => DB0005 [Status] => 2 [SubStatus] => [Date] => 2018-07-12 [Term] => 14 [PayBefore] => 2018-07-26 [PaymentURL] => https://www.xxx.nl/paymenturl?889430?key?whatever?invoices:dfsdfwe93

At this moment my tablefield is filled with the word array instead of the PaymentURL.

Who can help me a bit further