I'd like to know if there is any way to simplify this:
$transactions = $database->fetchAll("SELECT * FROM transactions WHERE user = :user", array(":user" => $USER["id"]));
$transactions_cleaned = array();
foreach($transactions as $transaction){
unset($transaction["id"]);
unset($transaction["user"]);
array_push($transactions_cleaned, $transaction);
}
It basically removes each id
and user
variables for each object of the following array:
Array
(
[0] => Array
(
[id] => 1
[user] => 1
[type] => deposit
[amount] => 1000
)
[1] => Array
(
[id] => 2
[user] => 1
[type] => withdraw
[amount] => 1000
)
)
So it becomes like this:
Array
(
[0] => Array
(
[type] => deposit
[amount] => 1000
)
[1] => Array
(
[type] => withdraw
[amount] => 1000
)
)