} // END - if
// Take all string elements
- if (("".bigintval($matches[4][$key])."" != $matches[4][$key]) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
+ if ((is_string($matches[4][$key])) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
// Replace it in the code
$newMatch = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $match);
$code = str_replace($match, $newMatch, $code);
function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums = false)
{
$dummy = $array;
- while ($primary_key < count($a_sort))
- {
- foreach ($dummy[$a_sort[$primary_key]] as $key => $value)
- {
- foreach ($dummy[$a_sort[$primary_key]] as $key2 => $value2)
- {
+ while ($primary_key < count($a_sort)) {
+ foreach ($dummy[$a_sort[$primary_key]] as $key => $value) {
+ foreach ($dummy[$a_sort[$primary_key]] as $key2 => $value2) {
$match = false;
- if (!$nums)
- {
+ if (!$nums) {
// Sort byte-by-byte (also numbers will be interpreted as chars! E.g.: "9" > "10")
if (($key != $key2) && (strcmp(strtolower($dummy[$a_sort[$primary_key]][$key]), strtolower($dummy[$a_sort[$primary_key]][$key2])) == $order)) $match = true;
- }
- elseif ($key != $key2)
- {
+ } elseif ($key != $key2) {
// Sort numbers (E.g.: 9 < 10)
if (($dummy[$a_sort[$primary_key]][$key] < $dummy[$a_sort[$primary_key]][$key2]) && ($order == -1)) $match = true;
if (($dummy[$a_sort[$primary_key]][$key] > $dummy[$a_sort[$primary_key]][$key2]) && ($order == 1)) $match = true;
}
- if ($match)
- {
+
+ if ($match) {
// We have found two different values, so let's sort whole array
- foreach ($dummy as $sort_key => $sort_val)
- {
+ foreach ($dummy as $sort_key => $sort_val) {
$t = $dummy[$sort_key][$key];
$dummy[$sort_key][$key] = $dummy[$sort_key][$key2];
$dummy[$sort_key][$key2] = $t;
unset($t);
- }
- }
- }
- }
+ } // END - foreach
+ } // END - if
+ } // END - foreach
+ } // END - foreach
// Count one up
$primary_key++;
- }
+ } // END - while
// Write back sorted array
$array = $dummy;
// Filter all numbers out
$ret = preg_replace("/[^0123456789]/", "", $num);
+ // Shall we cast?
+ if ($castValue) $ret = (double)$ret;
+
+ // Has the whole value changed?
+ if ("".$ret."" != "".$num."") {
+ // Log the values
+ DEBUG_LOG(__FUNCTION__.": num={$num},ret={$ret}");
+ } // END - if
+
// Return result
return $ret;
}