summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 4c049888be..f6b9ae5708 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -256,6 +256,9 @@ PHP_FUNCTION(count)
/* Numbers are always smaller than strings int this function as it
* anyway doesn't make much sense to compare two different data types.
* This keeps it consistant and simple.
+ *
+ * This is not correct any more, if you want this behavior, use
+ * array_type_data_compare().
*/
static int array_data_compare(const void *a, const void *b)
{
@@ -346,7 +349,8 @@ static int array_natural_case_compare(const void *a, const void *b)
return array_natural_general_compare(a, b, 1);
}
-/* Compare types first, and compare data only if same type */
+/* Compare types first, if exactly one argument is a string, return the
+ * type difference, thus numbers are always smaller than strings */
static int array_type_data_compare(const void *a, const void *b)
{
Bucket *f;
@@ -364,10 +368,9 @@ static int array_type_data_compare(const void *a, const void *b)
second = *((pval **) s->pData);
diff = first->type - second->type;
- if (diff)
+ if (diff && ((first->type == IS_STRING) || (second->type == IS_STRING)))
return diff;
-
if (ARRAYG(compare_func)(&result, first, second) == FAILURE) {
return 0;
}