How can arrays be used to read and manipulate text file content in PHP?

To read and manipulate text file content in PHP using arrays, you can read the file line by line into an array using the file() function. Once the file content is stored in an array, you can manipulate the data as needed by iterating through the array and performing operations on each line.

$fileContent = file('example.txt'); // Read file content into an array

foreach ($fileContent as $line) {
    // Manipulate each line as needed
    echo strtoupper($line); // Example: Convert each line to uppercase and output
}