Array Help

Hi, I am trying to do a couple of things which I think should be fairly simple, but I am struggling…

Issue 1
I have a simple array of prices. I am finding the ‘available saving’ by shopping with the lowest priced place compared with the highest priced.
[php]<?php echo max(array_filter($retailers));?>
Save £<?php echo (max(array_filter($retailers))-min(array_filter($retailers)));?>[/php]

This works - BUT I want to wrap it into an IF statement, so that it doesn’t show a saving if the answer is 0. (Currently I get (Save £0) on some items… Whenever I try, it breaks the site, (Nothing loads past the first time this runs) so I am clearly doing something wrong.

Issue 2
I have a simple array - Prices in column 1, URLs in column 2.

I was to lookup the MIN value of column 1, and return the corresponding URL. Again, sounds simple, but I cant get it working?

Any help much appreciated, and I am sorry for what are potentially 2 very stupid questions. I’ve only been involved in writing in PHP for about a month! Thanks again.

Just show some attempts and the issues you are running into.

Sponsor our Newsletter | Privacy Policy | Terms of Service