我想将名为CONTENT_VALUE的字段的所有值移动到数组变量。现在我发现错误json_decode()期望参数1是字符串,给定数组
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let buttonConnect = UIButton()
buttonConnect = UIButton(frame: CGRect(x:0, y:335, width:120, height:40))
buttonConnect.backgroundColor = UIColor(red: 0.8, green: 0.6, blue: 0.2, alpha: 1.0)
buttonConnect.setTitle("Connect", forState: .Normal)
buttonConnect.tag = 3
buttonConnect.addTarget(self, action: "btnConnectTouched:", forControlEvents: .TouchUpInside)
self.view.addSubview(buttonConnect)
}
func btnConnectTouched(sender: UIButton!) {
print("button connect touched");
}
答案 0 :(得分:0)
只需在json_decode函数中将第二个参数设置为true:
//...
$bulk=json_decode($fet_pic['CONTENT_VALUE'], true);
//...
答案 1 :(得分:0)
在将JSON字段附加到数组之前解码它:
while( $fet_pic = mysql_fetch_array($albpic) )
$album[] = json_decode( $fet_pic['CONTENT_VALUE'] );