我需要获得品牌:“你好世界” 当我使用json发送帖子数据并使用
获取时 $input = Input::all();
然后用
die(print_r($input));
这是写的
Array ([[], {brand: "hello world"}, [], 1427154586016])1
并且
我尝试使用json_encode并使用
die(print_r($encode));
此
{data: "{"brand":"Hello world"}", dc: "142715"}1
现在,如果我这样做
$ brand = $ encode ['data']或$ brand = $ encode ['brand']
我收到错误。 如何获得var $ brand的Hello world
答案 0 :(得分:1)
当你应该使用 json_decode()时,看起来你正在使用 json_encode()。但是就像kamlesh指出的那样,你的原始JSON数据似乎不是有效的JSON,所以这对你没有帮助。 This wiki article has an example of valid syntax.
另外,如果你正在使用laravel,你可以使用辅助函数 dd(),它将 die()和 var_dump()强>自动为你,节省你一点时间。
希望这可以解决您的问题,但如果没有,read the docs for the Input。应该有一些东西让你走上正轨。