0

I'm currently trying to clean up my array. array_unique() doesn't bring the hoped solution for this. I'm getting to different arrays from 2 different database queries. Both are getting the array infos with mysqli_fetch_array().

This is my code. The MySQL-queries doesn't matter at this point:

$gti = mysqli_fetch_array($get_trans_info_query);
$gt = mysqli_fetch_array($get_trans_query);

$returnInfoArray['transaction'] = $gt;
$returnInfoArray['transaction_info'] = $gti;
return $returnInfoArray;

//Calling the function now:
$transInfo = $payment->getTransactionInfo($transId, $userInfo['id']);
echo "<br><pre>";
print_r($transInfo);
echo "</pre><br>";

This brings me now this:

One thing I can do is to add every column into that array, but I hope that this could be done quicker. I don't want these array positions ([0], [1], etc.) but only the column names without writing the array manually into it.

Is there a way to do it?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Lukas
  • 408
  • 4
  • 10
  • 1
    Then why are you using `mysqli_fetch_array`? Use `mysqli_fetch_assoc` – Dharman Nov 14 '21 at 13:40
  • Omg thats it. I never used fetch_assoc - i didn't know, that assoc does perfectly that.. Thank you! – Lukas Nov 14 '21 at 13:42
  • 1
    Please read the manual. Everything is described here https://www.php.net/manual/en/mysqli-result.fetch-array.php – Dharman Nov 14 '21 at 13:43

0 Answers0