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 :'(

Link to comment
Share on other sites

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  :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.