Is it better to store data in a two-dimensional array or in properties of a class when working with Smarty in PHP?

When working with Smarty in PHP, it is generally better to store data in properties of a class rather than a two-dimensional array. This is because using properties of a class allows for better organization and encapsulation of data, making it easier to manage and access. Additionally, using a class allows for the implementation of methods to manipulate the data, providing more flexibility and control.

class DataHolder {
    private $data = [];

    public function setData($key, $value) {
        $this->data[$key] = $value;
    }

    public function getData($key) {
        return $this->data[$key];
    }
}

// Example usage
$dataHolder = new DataHolder();
$dataHolder->setData('name', 'John');
$dataHolder->setData('age', 30);

$smarty->assign('data', $dataHolder);