Jump to content

Sorting price list


puretony

Recommended Posts

Separate the prices by dashes or commas:

 

1.10-1.15-2.50-3.45-7.10-8.90

 

Then...

<?php
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$file = fread($handle, filesize($filename));

$prices = explode('-', $file);
sort($prices);

echo "Cheapest : \$" . $price[0] ;
echo "<br/>\n";
echo "Most expensive : \$" . $price[count($price)-1];
?>

Link to comment
https://forums.phpfreaks.com/topic/176345-sorting-price-list/#findComment-929469
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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