0

I have this so far :

if (is_request_var('requestor') == 'PPA'){
   $dataJson[][]  = array("status" => "success","value" => $fetchValue ,"postcode" => $fetchPostCode,"params"=>""); 

   $notice = $dataJson;
}

I want to get (refer below) from PHP how do i arrange my PHP array code

jQuery191013316784294951245_1485527378760([
  {
    "value": "\u003cstrong\u003eNAIROBI\u003c/strong\u003e KENYATTA AVENUE, GENERAL POST OFFICE, 00100",
    "postcode": "00100"
  },
  {
    "value": "\u003cstrong\u003eNAIROBI\u003c/strong\u003e HAILE SALASSIE AVENUE, CITY SQUARE, QLD, 00200",
    "postcode": "00200"
  }
])
3
  • You should use json_encode function: json_encode(array("status" =>..... and return it. Commented Feb 4, 2017 at 12:41
  • @rescobar would it return the way i want my json data formatted ? Commented Feb 4, 2017 at 12:43
  • @ Philip W Mars , It will return the JSON representation of a value, in this case of an array. Commented Feb 4, 2017 at 12:50

1 Answer 1

1

Try this:

$dataJson = array("value" => $fetchValue, "postcode" => $fetchPostCode);
$notice = json_encode($dataJson);
echo $notice;

Returns a string containing the JSON representation of value.

http://php.net/manual/en/function.json-encode.php

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.