What is the best way to add a new subarray to the $tabelle array in PHP?
To add a new subarray to the $tabelle array in PHP, you can simply use square brackets notation to append the new subarray to the existing array. This can be done by assigning the new subarray to a specific index in the $tabelle array or by using the array_push() function to add it at the end.
// Existing $tabelle array
$tabelle = array(
array('name' => 'Alice', 'age' => 25),
array('name' => 'Bob', 'age' => 30)
);
// Adding a new subarray to the $tabelle array
$newSubarray = array('name' => 'Charlie', 'age' => 35);
$tabelle[] = $newSubarray;
// Alternatively, using array_push()
$newSubarray2 = array('name' => 'David', 'age' => 40);
array_push($tabelle, $newSubarray2);
// Output the updated $tabelle array
print_r($tabelle);