
thinkphp php数组 转换 Js数组[] 150
模版代码:publicfunctionpchart(){$stock=D('Stock');$sidlist=$stock->where($map)->getField(...
模版代码 :
public function pchart(){
$stock = D('Stock');
$sidlist=$stock->where($map)->getField('id',true);
$re_map['sid']=array('in',implode(',',$sidlist));
$record = D('Record');
$relist=$record->order('sid asc,recordtime asc')->where($re_map)->select();
foreach($relist as $key=>$v){
$re[$v['rid']][$v['sid']][date('Y-m',strtotime($v['recordtime']))]=$re[$v['rid']][$v['sid']][date('Y-m',strtotime($v['recordtime']))]+$v['quantity'];
}
$a= json_encode($re[1][1]);
dump($re[1]);
$this->assign('re',$re[1]);
$this->display();
}
页面:
ar lines = r.linechart(
20, // X start in pixels
10, // Y start in pixels
600, // Width of chart in pixels
400, // Height of chart in pixels
[0,1,2,3,4,5,6,7,8,9,10,11], // Array of x coordinates equal in length to ycoords
[[0, 0, 0, 0, 0, 65, 1, 9, 0, 0, 0, 0],[0,0,0,0,0,14,0,0,0,0,0,0]], // Array of y coordinates equal in length to xcoords
options // opts object
).hoverColumn(function () {
this.tags = r.set();
for (var i = 0, ii = this.y.length; i < ii; i++) {
this.tags.push(r.tag(this.x, this.y[i], this.values[i], 160, 10).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }]));
}
}, function () {
this.tags && this.tags.remove();
});
我需要把类似的数组$this->assign('re',$re[1]);
转换城JS中的 [[0, 0, 0, 0, 0, 65, 1, 9, 0, 0, 0, 0],[0,0,0,0,0,14,0,0,0,0,0,0]] 形式
array (size=15)
1 =>
array (size=3)
'2014-06' => int 65
'2014-07' => int 1
'2014-09' => int 9
2 =>
array (size=1)
'2014-06' => int 14
3 =>
array (size=1)
'2014-06' => int 32
4 =>
array (size=1)
'2014-06' => int 31
5 =>
array (size=1)
'2014-06' => int 5
7 =>
array (size=1)
'2014-06' => int 8
8 =>
array (size=1)
'2014-06' => int 24
10 =>
array (size=1)
'2014-06' => int 50 展开
public function pchart(){
$stock = D('Stock');
$sidlist=$stock->where($map)->getField('id',true);
$re_map['sid']=array('in',implode(',',$sidlist));
$record = D('Record');
$relist=$record->order('sid asc,recordtime asc')->where($re_map)->select();
foreach($relist as $key=>$v){
$re[$v['rid']][$v['sid']][date('Y-m',strtotime($v['recordtime']))]=$re[$v['rid']][$v['sid']][date('Y-m',strtotime($v['recordtime']))]+$v['quantity'];
}
$a= json_encode($re[1][1]);
dump($re[1]);
$this->assign('re',$re[1]);
$this->display();
}
页面:
ar lines = r.linechart(
20, // X start in pixels
10, // Y start in pixels
600, // Width of chart in pixels
400, // Height of chart in pixels
[0,1,2,3,4,5,6,7,8,9,10,11], // Array of x coordinates equal in length to ycoords
[[0, 0, 0, 0, 0, 65, 1, 9, 0, 0, 0, 0],[0,0,0,0,0,14,0,0,0,0,0,0]], // Array of y coordinates equal in length to xcoords
options // opts object
).hoverColumn(function () {
this.tags = r.set();
for (var i = 0, ii = this.y.length; i < ii; i++) {
this.tags.push(r.tag(this.x, this.y[i], this.values[i], 160, 10).insertBefore(this).attr([{ fill: "#fff" }, { fill: this.symbols[i].attr("fill") }]));
}
}, function () {
this.tags && this.tags.remove();
});
我需要把类似的数组$this->assign('re',$re[1]);
转换城JS中的 [[0, 0, 0, 0, 0, 65, 1, 9, 0, 0, 0, 0],[0,0,0,0,0,14,0,0,0,0,0,0]] 形式
array (size=15)
1 =>
array (size=3)
'2014-06' => int 65
'2014-07' => int 1
'2014-09' => int 9
2 =>
array (size=1)
'2014-06' => int 14
3 =>
array (size=1)
'2014-06' => int 32
4 =>
array (size=1)
'2014-06' => int 31
5 =>
array (size=1)
'2014-06' => int 5
7 =>
array (size=1)
'2014-06' => int 8
8 =>
array (size=1)
'2014-06' => int 24
10 =>
array (size=1)
'2014-06' => int 50 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏150(财富值+成长值)
1个回答
2015-08-13
展开全部
public static boolean isNumeric(String str){
for (int i = str.length();--i>=0;){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}
for (int i = str.length();--i>=0;){
if (!Character.isDigit(str.charAt(i))){
return false;
}
}
return true;
}
追问
我要的是页面上针对Js中的数组进行循环
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询