What are the advantages of combining related data fields in PHP arrays, as opposed to storing them separately?

Combining related data fields in PHP arrays can make the data more organized and easier to manage. It can also improve the efficiency of data retrieval and manipulation, as all related information is stored together. Additionally, it can simplify the code by reducing the number of variables needed to store the data.

// Combining related data fields in PHP arrays
$user = [
    'name' => 'John Doe',
    'age' => 30,
    'email' => 'johndoe@example.com'
];

// Accessing the data
echo $user['name']; // Output: John Doe
echo $user['age']; // Output: 30
echo $user['email']; // Output: johndoe@example.com