I have channel entries with around 20 number fields, each containing a price: {price_1}, {price_2}, etc.

I need to display the lowest of these prices in the entry's template but am finding it strangely difficult to do!

My PHP skills are just copy and paste level, and I thought I could just do:

echo min({price_1},{price_2}...)

But some of the price fields may be empty, so I am getting PHP errors.

Any help gratefully received!


1 Answer 1


How about this?

$list = array('{price_1}','{price_2}','{price_3}','{price_4}');
$result = array_filter( $list, 'strlen' );
echo min($result); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.