added a json encode function to PHP