How can PHP arrays be used to simplify variable manipulation?
Using PHP arrays can simplify variable manipulation by allowing you to store multiple values in a single variable. This can make it easier to manage and manipulate data, especially when working with large datasets or complex data structures. You can use array functions such as foreach, array_map, and array_filter to iterate over and manipulate the values in an array efficiently.
// Example of using PHP arrays to simplify variable manipulation
// Create an array of numbers
$numbers = [1, 2, 3, 4, 5];
// Multiply each number in the array by 2
foreach ($numbers as $key => $value) {
$numbers[$key] = $value * 2;
}
// Print the modified array
print_r($numbers);