Home > Blockchain >  Get String of array_slice
Get String of array_slice

Time:11-21

DataTable::get(...) returns an array with five with 5 values, which I simply want to store into variables to use them in a html text then. Since I'm new to PHP, I completely don't know, how to fix them. :/

Thanks in Advance!

$result = DataTable::get($bankingTable, ["iban", "pin", "category", "bank", "uuid"], ["iban='" . $iban . "'"]);
$iban = array_slice($result, 0, 1);
$pin = array_slice($result, 1, 1);
$category = array_slice($result, 2, 1);
$bank = array_slice($result, 3, 1);
$uuid = array_slice($result, 4, 1);

I've already tried a lot, just like adding a [0] at the end of each line, what didn't work. I'm expecting to use the variables just like strings in my text.

CodePudding user response:

You can use extract to do this.

Example:

$result = DataTable::get($bankingTable, ["iban", "pin", "category", "bank", "uuid"], ["iban='" . $iban . "'"]);


extract($result[0]);
// You can now access things like $iban, $pin, $category, etc.

var_dump($iban);
  • Related