PHP: Extract value from JSON array

前端 未结 2 1147
失恋的感觉
失恋的感觉 2021-01-28 15:01

I have an API that takes parameters from a post through JSON and I want to extract one of the values in an array for a key value pair. However, despite many attempts, I can\'t

相关标签:
2条回答
  • 2021-01-28 15:36

    From your code above $json is a string and not a json object, your should use $request to access numberofhits

    $request['numberofhits']
    
    0 讨论(0)
  • 2021-01-28 15:39

    If your $parameters just shows {"numberofhits":"5"}, this means your post request just returned a json of a json. Try json decoding $parameters again like json_decode($parameters, true); and log that result. It should log the desired array.

    0 讨论(0)
提交回复
热议问题