Reading From a Text File with Delimiters

This script pulls data, row by row, from a comma-delimited text file and shows it on the page.

Each line of the text file has three fields, separated by commas. This script breaks up each row into an array with three elements using the built-in PHP explode() function.

Click here to add a new row to the text file

image path caption username
files/image1.jpg this is the caption for the first image amos
files/image2.jpg this is the caption for the second image amos
files/image3.jpg this is the caption for the third image amos
files/testing.jpg this is a test amos_again
j;akd wow jackie
test test test
http://upload.wikimedia.org/wikipedia/commons/4/4b/Everest_kalapatthar_crop.jpg was here Joe
moe freely seymour
nba on abc pchoy
odi oma chi

If you're confused, it may help to visualize what the $arrLines array looks like by using the built-in print_r() function, which just ouputs the raw array data:

Array
(
    [0] => Array
        (
            [0] => files/image1.jpg
            [1] => this is the caption for the first image
            [2] => amos

        )

    [1] => Array
        (
            [0] => files/image2.jpg
            [1] => this is the caption for the second image
            [2] => amos

        )

    [2] => Array
        (
            [0] => files/image3.jpg
            [1] => this is the caption for the third image
            [2] => amos

        )

    [3] => Array
        (
            [0] => files/testing.jpg
            [1] => this is a test
            [2] => amos_again

        )

    [4] => Array
        (
            [0] => j;akd
            [1] => wow
            [2] => jackie

        )

    [5] => Array
        (
            [0] => test
            [1] => test
            [2] => test

        )

    [6] => Array
        (
            [0] => 
            [1] => 
            [2] => 

        )

    [7] => Array
        (
            [0] => http://upload.wikimedia.org/wikipedia/commons/4/4b/Everest_kalapatthar_crop.jpg
            [1] => was here
            [2] => Joe

        )

    [8] => Array
        (
            [0] => moe
            [1] => freely
            [2] => seymour

        )

    [9] => Array
        (
            [0] => 
            [1] => nba on abc
            [2] => pchoy

        )

    [10] => Array
        (
            [0] => odi
            [1] => oma
            [2] => chi

        )

    [11] => Array
        (
            [0] => 
        )

)