I need to encode a javascript function into a JSON object in PHP.
This:
$function = \"function(){}\";
$message = \"Hello\";
$json = array(
This function can also help:
function jsonify($var){
return str_ireplace(array("'function",'"function',"}'",'}"'),array("function",'function',"}",'}'),json_encode($var));
}
Taken from here: http://network.convergenceservices.in/forum/105-uknowva-development/4710-introducing-convhelperjsonify-in-uknowva-251.html#4710