What are some strategies for organizing and storing values in PHP arrays for future use?

When organizing and storing values in PHP arrays for future use, it is important to structure the array in a logical way that makes it easy to access and manipulate the data. One strategy is to use associative arrays where each value is assigned a key that describes its purpose or relationship to other values. Another strategy is to use multidimensional arrays to group related values together. Additionally, using functions like array_push() or array_merge() can help add or combine values in the array efficiently.

// Example of organizing and storing values in PHP arrays using associative arrays and multidimensional arrays

// Associative array
$user = [
    'name' => 'John Doe',
    'email' => 'john.doe@example.com',
    'age' => 30
];

// Multidimensional array
$users = [
    [
        'name' => 'John Doe',
        'email' => 'john.doe@example.com',
        'age' => 30
    ],
    [
        'name' => 'Jane Smith',
        'email' => 'jane.smith@example.com',
        'age' => 25
    ]
];

// Adding values to an array
$fruits = ['apple', 'banana'];
array_push($fruits, 'orange', 'grape');

// Merging arrays
$vegetables1 = ['carrot', 'broccoli'];
$vegetables2 = ['spinach', 'cucumber'];
$combinedVegetables = array_merge($vegetables1, $vegetables2);