sorting fields within a record

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 18, 2012   (RSS)

Re: [Deborah] sorting fields within a record

By Jason - June 18, 2012

Hi Deborah,

You can try using the PHP min() function to get the lowest numerical value like this:

EXAMPLE:
$price = min($record['price_option_01'], $record['price_option_02'], $record['price_option_03']);

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] sorting fields within a record

By Deborah - June 18, 2012

Hi, Jason.

Yes! That is the solution I needed. After plugging in the function, I realized I need to account for null fields, so I went online and found a way to filter those out. (Might be of help to someone else.)

The following returns lowest numerical value and ignores null fields:

$min = array($record['option_01_price'], $record['option_02_price'], $record['option_03_price']);
$min = array_filter($min);
echo min($min);


Thanks very much for your help!
~ Deborah