Jump to main content Jump to doc navigation

xPDO::toJSON

Converts a PHP array into a JSON encoded string.

Syntax

API Docs: https://api.modx.com/revolution/2.2/db_core_xpdo_xpdo.class.html#\xPDO::toJSON()

string toJSON (array $array)

Example

$ar = array('name' => 'John');
$str = $xpdo->toJSON($ar);
echo $str; // prints: {name:"John"}

See Also