这就是我想要的结果
driver.get("http://www.medinfi.com");
driver.findElement("city-locality1").sendKeys("Mumbai",Keys.DOWN);
我已经并列了:
{
name: 'creditor',
y: 5600
}, {
name: 'Supplier',
y: 2400,
}, {
name: 'Normal',
y: 1038
}, {
name: 'Suppliers',
y: 4377
},
但现在我在array_push
得到一个非法的字符串偏移量我如何从php生成json?
答案 0 :(得分:2)
你必须这样做: -
$roles = AllUserRoles::find()->all();
$userdata = [];
foreach ($roles as $role) {
$name = $role["description"];
$trucks = TblTrucks::find()->where(['role_id'=>$role["id"]])->count();
$userdata[] = ['name'=>$name,'y'=> $trucks]; // assign data directly
}
return json_encode($userdata);