php - How to split json array response into a variable? -
here code, got exact array response. example there details called title
in response. how can split titles variables?
say title=ship,title=box
. how can result?
<?php $url = ""; /*var_dump(parse_url($url)); var_dump(parse_url($url, php_url_pass));*/ $json = file_get_contents("http://svcs.ebay.com".$url.""); $data = json_decode($json,true); //$key="title"; //$title = $data[$key]; // option 2: through use of object. //$title=array_shift($data); //$c=array("title"=); foreach ($data $key => $val) { //echo "$key = $val\n"; print "<tr><td>" . $key . "</td><td>" . $val['value1'] . "</td><td>" . $val['value2'] . "</td></tr>"; } ?>
buddy! can use extract() function after decoding json https://www.w3schools.com/php/func_array_extract.asp
i-e extract($data)
then can use line of code view defined variables
echo "<pre>"; var_dump(get_defined_vars());
Comments
Post a Comment