Php 在zend框架中将longtext排序为int

Php 在zend框架中将longtext排序为int,php,zend-framework,Php,Zend Framework,数据排序不正确,看起来像 0 1 10 11 2 20 21 3 这是我的订单代码 $select->order('post_meta.meta_value AS int desc'); 请注意,meta\u value字段是长文本的,不是int,无法更改它来解决问题。需要另一个解决方案。好的,根据您的评论问题,如何在php中对其排序,我可以想到类似这样的事情: <?php $stringArray = [0, '1', 10, '11 2', '20 21

数据排序不正确,看起来像

0  
1  
10  
11 2  
20 21  
3
这是我的订单代码

$select->order('post_meta.meta_value AS int desc');

请注意,
meta\u value
字段是长文本的,不是int,无法更改它来解决问题。需要另一个解决方案。

好的,根据您的评论问题,如何在php中对其排序,我可以想到类似这样的事情:

<?php

$stringArray = [0, '1', 10, '11 2', '20 21', 3];

usort($stringArray, function($a, $b) {

    $a = (int)trim(preg_replace('/\s+/', '', $a));
    $b = (int)trim(preg_replace('/\s+/', '', $b));

    if ($a === $b) {
        return 0;
    }
    return ($a > $b) ? -1 : 1;
});

var_dump($stringArray);
?>


您可以添加排序列,也可以在php中对其排序。如何在php中对其排序