I have abit of a silly question. I was just wondering. Whilst coding im sometimes tend to, if I have lot of variables that relate to a specific entity, create an associative array using key value pairs to define these entities.
What Id like to know is, Im aware that they all get saved in memory but which method is smaller/faster, creating a few variables or creating an array with keys and values of the variables
Below are some examples:
$apples = 'apples';
$grapes = 'some grapes';
$bananas = 'lots of bananas';
$fruits = ['apples' => 'apples', 'grapes' => 'some grapes', 'bananas' => 'lots of bananas'];
What I'll be using this for is looping over entries from the database and defining values to populate in my markup.