How can PHP functions like explode and array_slice be used to manipulate data from a text file in PHP?
To manipulate data from a text file in PHP, you can use functions like explode and array_slice. First, read the contents of the text file into a variable. Then, use explode to split the data into an array based on a delimiter (such as a comma or space). Finally, use array_slice to extract a portion of the array for further manipulation.
// Read the contents of the text file into a variable
$data = file_get_contents('data.txt');
// Split the data into an array based on a delimiter
$dataArray = explode(',', $data);
// Extract a portion of the array for manipulation
$subsetArray = array_slice($dataArray, 0, 5);
// Now you can work with the subsetArray as needed