I’m trying to loop through an array backwards, so I figured I could try
$Array = Array("One", "Two", "Three", "Four", "Five");
For ($Entry = Amount_of_values($Array); $Entry = 0; $Entry = $Entry-1){
Echo $Array[$Entry] . " "; //Should be Five Four Three Two One
}
but I have no idea how to retrieve the amount of values in an array ( Amount_of_values($Array) in the example). What’s the function I’m looking for?
Thanks in advance!
Edit: Little additional question: why should it be $Entry >= 0 in the for loop, isn’t the last thing I want to output $Array[0]?
There’s a better way of doing what your code snippet does – using
implodeandarray_reverse:The answer to your actual question though, is if you want to count the number of entries in an array, you want
count.