I know it may seem a little confusing for a title but lets say I had this:
{"success":true,"name":"test","ips":[{"public":"ipaddr","local":"ipaddr"},{"public":"ipaddr","local":"ipaddr"}],"time":1040}
Since there are two "public" ip addresses, I only want to display the first public ip in the list. How would I go about doing that?
This is what I have so far:
$json = json_decode($contents, true);
foreach($json['ips'] as $item) {
echo $item['public'];
}