You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== json_encode ==
Copy Code
The output would be:
Converts an array into a JSON encoded string. Both normal and associative arrays are supported. Within the array, only primitives and arrays can be encoded.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| json_encode
|-
! scope="row" | Returns
| string
|-
! scope="row" | Usages
| array
|-
! scope="row" | Throws
| [[../objects/ms.lang.CastException|ms.lang.CastException]]
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| None
|}
=== Usages ===
json_encode(array)=== Examples === ====Example 1==== Simple usage Given the following code:
json_encode(array(emptyObject: associative_array(), anArray: array(1, 2, 3), anObject: array(one: 1, two: 2)));

1 {{function|json_encode}}({{function|array}}(emptyObject: {{function|associative_array}}(), anArray: {{function|array}}(1, 2, 3), anObject: {{function|array}}(one: 1, two: 2)));
NOWIKI
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)