0

Below is my working code but when I am trying to 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"
}
2
  • Check this line $result->body->Telecom circle try to remove space between Telecom and circle Commented Jul 18, 2015 at 7:23
  • not working, I already tried. Commented Jul 18, 2015 at 7:26

1 Answer 1

2

Your code should be :

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;  
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.