Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions noutrace.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,12 @@ public function usortByArrayKey(&$array, $key, $asc=SORT_ASC)
$sort_flags = array(SORT_ASC, SORT_DESC);
if (!in_array($asc, $sort_flags))
throw new InvalidArgumentException('sort flag only accepts SORT_ASC or SORT_DESC');
$cmp = function(array $a, array $b) use ($key, $asc, $sort_flags)
{
$cmp = create_function('array $a, array $b use $key, $asc, $sort_flags','
if (!is_array($key))
{ //just one key and sort direction
if (!isset($a[$key]) || !isset($b[$key]))
{
throw new Exception('attempting to sort on non-existent keys');
throw new Exception(\'attempting to sort on non-existent keys\');
}
if ($a[$key] == $b[$key])
return 0;
Expand All @@ -89,24 +88,24 @@ public function usortByArrayKey(&$array, $key, $asc=SORT_ASC)
{ //using multiple keys for sort and sub-sort
foreach ($key as $sub_key => $sub_asc)
{
//array can come as 'sort_key'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which
//array can come as \'sort_key\'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which
if (!in_array($sub_asc, $sort_flags))
{
$sub_key = $sub_asc;
$sub_asc = $asc;
}
//just like above, except 'continue' in place of return 0
//just like above, except \'continue\' in place of return 0
if (!isset($a[$sub_key]) || !isset($b[$sub_key]))
{
throw new Exception('attempting to sort on non-existent keys');
throw new Exception(\'attempting to sort on non-existent keys\');
}
if ($a[$sub_key] == $b[$sub_key])
continue;
return ($sub_asc == SORT_ASC xor $a[$sub_key] < $b[$sub_key]) ? 1 : -1;
}
return 0;
}
};
');
usort($array, $cmp);
}

Expand Down Expand Up @@ -378,6 +377,7 @@ public function trace()

for ($jI = 11; $jI <= 10 + $jData[10]; $jI++)
{
$jData[$jI]=str_replace('<!--', '&lt;!--', $jData[$jI]); //The Fix for situation: if appeared tag "<!--" in the values of variables then it comments out the remains of result output. That was unexpected.
echo "<li class=\"parm\">{$jData[$jI]}</li>";
}
echo "</ul>";
Expand Down
12 changes: 6 additions & 6 deletions trace.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ function aryComp($a, $b)
function usortByArrayKey(&$array, $key, $asc=SORT_ASC) {
$sort_flags = array(SORT_ASC, SORT_DESC);
if(!in_array($asc, $sort_flags)) throw new InvalidArgumentException('sort flag only accepts SORT_ASC or SORT_DESC');
$cmp = function(array $a, array $b) use ($key, $asc, $sort_flags) {
$cmp = create_function('array $a, array $b use $key, $asc, $sort_flags','
if(!is_array($key)) { //just one key and sort direction
if(!isset($a[$key]) || !isset($b[$key])) {
throw new Exception('attempting to sort on non-existent keys');
throw new Exception(\'attempting to sort on non-existent keys\');
}
if($a[$key] == $b[$key]) return 0;
return ($asc==SORT_ASC xor $a[$key] < $b[$key]) ? 1 : -1;
} else { //using multiple keys for sort and sub-sort
foreach($key as $sub_key => $sub_asc) {
//array can come as 'sort_key'=>SORT_ASC|SORT_DESC or just 'sort_key', so need to detect which
//array can come as \'sort_key\'=>SORT_ASC|SORT_DESC or just \'sort_key\', so need to detect which
if(!in_array($sub_asc, $sort_flags)) { $sub_key = $sub_asc; $sub_asc = $asc; }
//just like above, except 'continue' in place of return 0
//just like above, except \'continue\' in place of return 0
if(!isset($a[$sub_key]) || !isset($b[$sub_key])) {
throw new Exception('attempting to sort on non-existent keys');
throw new Exception(\'attempting to sort on non-existent keys\');
}
if($a[$sub_key] == $b[$sub_key]) continue;
return ($sub_asc==SORT_ASC xor $a[$sub_key] < $b[$sub_key]) ? 1 : -1;
}
return 0;
}
};
')};
usort($array, $cmp);
}