What does it mean?
I am adding elements to an array and finally trying to convert this array to Json. Below is the code.
$SubCategoryList = array();
array_push($SubCategoryList,
array(
'SubCategoryID' => 1,
'FirstName' => 'First Name',
'LastName' => 'Last Name',
));
array_push($SubCategoryList,
array(
'SubCategoryID' => 2,
'FirstName' => 'First Name2',
'LastName' => 'Last Name2',
));
Above conclusion below
Array
(
[0] => Array
(
[SubCategoryID] => 1
[FirstName] => First Name
[LastName] => Last Name
)
[1] => Array
(
[SubCategoryID] => 2
[FirstName] => First Name2
[LastName] => Last Name2
)
)
Below is the code used to convert the array to Json.
<script>
var subCategoriesList = {{ json_encode($SubCategoryList) }};
</script>
and finally json prints below. What can be seen in the view source
var subCategoriesList = [{"SubCategoryID":1,"FirstName":
"First Name","LastName":"Last Name"},
{"SubCategoryID":2,"FirstName":"First Name2",
"LastName":"Last Name2"}];
Question
Why does it give "in json data?
user5694966
source
share