Original code: {code...} calculates an elegant and efficient array sorting algorithm. It seems that the simplest thing is: {code...} Don't know if there will be other problems with this conversion? Original code:
$web =List::Model()->findAll(array("condition"=>"id = 8}","order"=>"id asc"));$webs='';foreach($web as $k=>$v){ foreach($v as $ks=>$vs){ $webs[$k][$ks]=$vs; }}Response::json($webs);
Find an elegant and efficient array sorting algorithm.
The simplest is:
$web =List::Model()->findAll(array("condition"=>"id = 8}","order"=>"id asc"));Response::json(json_decode(CJSON::encode($web),TRUE));
I don't know if there are other problems with this conversion?
Reply content:
Original code:
$web =List::Model()->findAll(array("condition"=>"id = 8}","order"=>"id asc"));$webs='';foreach($web as $k=>$v){ foreach($v as $ks=>$vs){ $webs[$k][$ks]=$vs; }}Response::json($webs);
Find an elegant and efficient array sorting algorithm.
The simplest is:
$web =List::Model()->findAll(array("condition"=>"id = 8}","order"=>"id asc"));Response::json(json_decode(CJSON::encode($web),TRUE));
I don't know if there are other problems with this conversion?
Use markdown to edit the code.
Let me show you.
php
$web =List::Model()->findAll(array("condition"=>"id = 8}","order"=>"id asc")); $webs='';foreach($web as $k=>$v){ foreach($v as $ks=>$vs){ $webs[$k][$ks]=$vs; } }Response::json($webs);
Http://www.cnblogs.com/imxiu/p/3474367.html