-
Notifications
You must be signed in to change notification settings - Fork 0
arrayToJson
Corey Avis edited this page Sep 23, 2026
·
2 revisions
Converts a given PHP array into a JSON-formatted string. This is ideal for preparing data to be sent to API responses, JavaScript frontends, or for storage.
arrayToJson(array $array = []): string
array (array) : The array to convert.
(string) : Returns the JSON-encoded string representation of the array.
$cphp->arrayToJson(['id' => 10, 'user' => 'name', 'active' => true]);
// Result: {"id":10,"user":"name","active":true}
- Triggers a warning if there was an issue encoding the data.
arrayToObject | arrayToSerial | jsonToArray
Home | CoreyPHP | Conversion