Jump to content

[SOLVED] String Array containing numbers... how to convert for min() and max()?


5kyy8lu3

Recommended Posts

Hi.  I have an array with numbers in it but they were read in as strings.  Because of this I can't seem to get min() and max() to work properly since they aren't decimals.  Is there a way to convert the array to a decimal array or something so I can get the min() and max() values in the array?  I've tried walking through the array manually but I can't compare values when they're being evaluated as strings :'(

PHP's types are incredibly loose and you should be able to use max() and min() on virtually any array, including those that make no sense to use it on, it will cast them to int before checking...

 

Can you show us the code where min() and max() aren't working?

  Quote

PHP's types are incredibly loose and you should be able to use max() and min() on virtually any array, including those that make no sense to use it on, it will cast them to int before checking...

 

Can you show us the code where min() and max() aren't working?

actually you're absolutely right lol I was looking at the wrong data when comparing it to what my min and max were giving me, i used print_r() to be sure and sure enough i was just being stupid, thanks for the heads up  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.