So, say you have a php post script that appends whatever you pass to it to a text file as a new line
Let say the file is called file.txt and looks like this:
11:45 Am
12:49 PM
Went to Lunch
3:25 PM
I wanna know, how can I write a php script that treats information as pairs of 3.
so in a for loop it would display
line1 | line2 | line3
line4
Notice that there is nothing past line4, so it stopped.
You can use (demo)
This will output the desired
See the Manual entries for
file— Reads entire file into an array andarray_chunk— Split an array into chunksimplode— Join array elements with a string