php - How do I get max(); to display the highest value number rather than just "Array"? -


maximum ($ caption);
gives me this:
array

$ Captions are defined here:

  $ i = "0"; While ($ i & lt; $ count) {catalog ($ old caption, $ years, $ order) = explosion ("-", $ gallery directory [$ i]); $ Caption [$ year] [$ command] = str_replace ("_", "", "$ oldCaption"); Echo every year; // debug echo "
"; $ I ++; }

comes out to be years $ 2008
2009
2009

So how do I get the maximum ($ captions ); To give me the price of 2009 instead of Array?

I will also enter the whole code, but when I tried that it got dirty but I will try again so that you can see the whole picture

Use:

$ years = array_keys ($ caption); $ Maxewire = max ($ years); // or one-liner: $ maxyear = maximum (array_kiz ($ caption));

The reason for your code was not working because you were comparing the values ​​of array $ caption , which is another array. Maximizes () computation of integer values, using neither key nor arrays, $ captions to form another array in the form of values ​​of all years.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -