space in json response not converting to php object -


below working code when trying echo "telecom circle", getting error "parse error: syntax error, unexpected 'circle' (t_string)".

if ($_get['result']): $rslt = $_get['result']; $result = unirest\request::get("https://sphirelabs-mobile-number-portability-india-operator-v1.p.mashape.com/index.php?number=$rslt", array( "x-mashape-key" => "xxxxxxxxxxxxx", "accept" => "application/json" ) );  echo ($result->body->operator); echo($result->body->telecom circle); endif;   

api response :

{ "telecom circle": "delhi ncr", "operator": "vodafone", "is mnp": "false" } 

your code should :

just used $result->body->{'telecom circle'} instead of $result->body->telecom circle

if ($_get['result']): $rslt = $_get['result']; $result = unirest\request::get("https://sphirelabs-mobile-number-portability-india-operator-v1.p.mashape.com/index.php?number=$rslt", array( "x-mashape-key" => "xxxxxxxxxxxxx", "accept" => "application/json" ) );  echo ($result->body->operator); echo($result->body->{'telecom circle'}); endif;   

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -