mardi 4 août 2015

Find Next to Last Element in PHP Foreach

I need to write a script that returns the next-to-last element in a foreach loop. Something like the below concept. How would I go about doing so?

foreach($row as $r) {
    if (element index is last - 1) {
        echo "The next-to-last element is" . $r;
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire