I have the following code: (it's meant for setupNewGame() but is currently in getAllDatas() so I can debug it)
It's trimmed down here for clarity. For some reason, nothing gets added to $gear_assets. Nothing I do within array_map seems to make it to the global scope. I tested similar code on onlinephp.io here:
https://onlinephp.io?s=VZHbioMwEIavFXyH ... 2C&v=8.2.1
It worked as I expected in the above link, pushing new entries from within the callback function correctly added them to the global variable. For some reason though it's not working in game.php.
Code: Select all
$asset_deck = self::getObjectListFromDb("SELECT card_location_arg, card_type_arg, card_id FROM cards_and_tokens WHERE card_location='asset_deck'");
$gear_assets = [];
function sortAssets($asset) {
global $gear_assets;
$gear_assets[] = [$asset['card_location_arg'], $asset['card_id']];
}
array_map('sortAssets', $asset_deck);
https://onlinephp.io?s=VZHbioMwEIavFXyH ... 2C&v=8.2.1
It worked as I expected in the above link, pushing new entries from within the callback function correctly added them to the global variable. For some reason though it's not working in game.php.