PHP Include and sort by variable within file
- by Jason Hoax
I have written this PHP include-script but now I'm trying to sort the included files out by variables WITHIN the included php's.
In other words, in each included PHP file there is a rating, now I want the ratings to be read so that when they are included they will be sorted out from highest to lowest. (scores are like 6.0 to 9.0)
Kind Regards!
$location = 'experiments/visualizations';
foreach (glob("$location/*.php") as $filename)
{
include $filename;
}
The included files are named randomly like:
File1:
$filename = "AAAA";
$projecttitle = "Project Name";
$description = "This totally explains the product";
$score = "7.6";
File 2:
$filename = "BBBB";
$projecttitle = "Project Name2"
$description = "This totally explains the product";
$score = "9.6";
As you can see 9.6 is higher than 7.6 but PHP sorts the includes out by name instead of variables within the file. I tried sorting, but I can't get it fixed. Help!