开发者

Codeigniter sorting array values after array_unique

I'm trying to use sort function for an array after array_unique function but I'm getting below error:

A PHP Error was encountered
Severity: Warning
Message: implode() [function.implode]: Invalid arguments passed
Filename: controllers/admin.php
Line Number: 250

Below is my loop function. How can I sort by value ascending?

foreach ($bars as $bar){

                $explode = explode(',',$bar->dat开发者_JAVA百科e_id);
                $i = 0;
                $b = array();
                foreach($explode as $bars){
                        $bars = intval($bars);
                        @$b[$i] .= $bars;
                        $i++;
                }

                $date_id = array_unique($b);
                $date_id = sort($date_id);

                echo "<pre>";
                print_r($date_id);
                echo "</pre>";
                $date_id = implode(',',$date_id);
                echo "<pre>";
                print_r($date_id);
                echo "</pre>";
}


Among other things that look awry with your code, sort() returns TRUE or FALSE, not the sorted array.

Instead of this:

$date_id = array_unique($b);
$date_id = sort($date_id);

Use this:

$date_id = array_unique($b);
sort($date_id);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜