The json_encode function will convert a PHP array (or, since PHP 5.4, an object which implements the JsonSerializable interface) to a JSON-encoded string. It returns a JSON-encoded string on success or FALSE on failure.
$array = [
'name' => 'Jeff',
'age' => 20,
'active' => ...