Created
April 14, 2015 09:16
-
-
Save egulhan/bc7f93aeb65ba1b4c623 to your computer and use it in GitHub Desktop.
Determine if string is json encoded or not using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function isJsonEncoded($str) | |
{ | |
json_decode($str); | |
return json_last_error() == JSON_ERROR_NONE ? true : false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment