PHP Include and sort by variable within file

Posted by Jason Hoax on Stack Overflow See other posts from Stack Overflow or by Jason Hoax
Published on 2012-10-03T15:26:28Z Indexed on 2012/10/03 15:37 UTC
Read the original article Hit count: 207

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about php

Related posts about include