I have a PHP script in Wordpress that processes API data if it's an array but I'm having a figuring this out. Here is my PHP script:
$results = wp_remote_retrieve_body( wp_remote_get('https://...') ); $results = json_decode( $results ); if( ! is_array( $results ) || empty( $results ) ){ return false; } Here's what the API looks like. It' is not an array so how can I modify my above script to support this?:
{ "msg": "OK", "server_time": "2021-03-04 01:42:20", "status": 200, "result": { "total_pages": 2, "files": [ { "Country": "USA", "city": "NYC", "zip: "12345", }, { "Country": "RUSSIA", "city": "MOSCOW", "zip: "12345", }, https://stackoverflow.com/questions/66467986/how-can-i-modify-my-php-script-to-read-an-api-as-an-array March 04, 2021 at 11:05AM
没有评论:
发表评论