-2

I am trying to access the JSON content from the below URL and parse to extract and print the date value of "data.content.containers.container.locationDateTime"

iff the

"data.content.containers.container.label " has been set as "Empty Equipment Returned"

$url = 'https://elines.coscoshipping.com/ebtracking/public/containers/FCIU5238624';
$datax = file_get_contents($url);
$x = json_decode($datax);

could anyone help me please

Fizz Shan
  • 33
  • 6
  • You need to refine the question more. Do you want to do this on server side or client side? https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch – Matt Mar 05 '23 at 03:01
  • 1
    Your question is tagged JavaScript yet code is PHP, it's unclear what the question is, exactly. – Chaoz Mar 05 '23 at 03:10
  • @Matt I am trying to get this done at client side – Fizz Shan Mar 05 '23 at 03:23
  • @chaoz Basically I am trying to print the locationDateTime – Fizz Shan Mar 05 '23 at 03:24
  • Does this answer your question? [How to extract and access data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-to-extract-and-access-data-from-json-with-php) – Don't Panic Mar 05 '23 at 06:55

1 Answers1

1

This is work for me to extract and print the date value

$url = 'https://elines.coscoshipping.com/ebtracking/public/containers/FCIU5238624';
$datax = file_get_contents($url);
$x = json_decode($datax);
$dataTime = $x->data->content->containers[0]->container->locationDateTime;
print $dataTime;
Masunulla
  • 55
  • 3