$min_price=$config[‘video_play_price’];
$temp_price = $videos[‘video_play_price’];
if ($temp_price<$min_price) { $temp_price = $min_price;}
Many thanks
$min_price=$config[‘video_play_price’];
$temp_price = $videos[‘video_play_price’];
if ($temp_price<$min_price) { $temp_price = $min_price;}
Many thanks
It’s setting $temp_price
to either $config['video_play_price']
or $videos['video_play_price']
, whichever is higher.
If it’s the if
statement that’s confusing you, know that PHP doesn’t usually care about white space; the statement could just as easily (and should, in my opinion) be written as:
if ($temp_price < $min_price) {
$temp_price = $min_price;
}
It’s piece of code that checks whether the temporary ($temp_price
) is smaller than minimum price ($min_price
).
If it turns out that the temp price is smaller than the minimum, then the $temp_price
becomes the minimum price.
Seems like a common e-commerce scenario, where you can set minimum prices for your wares.
A better way would be to use the max() function
$temp_price=max($config[‘video_play_price’], $videos[‘video_play_price’]);