Skip to content

@KATT /define.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
/**
* Check if content is JSON
*
* @param string $content
* @return boolean
*/
function w3_is_json($content) {
return json_decode($content) !== NULL;
}
/**
* Check if content is JSONP
*
* @param string $content
* @return boolean
*/
function w3_is_jsonp($content) {
// Extract json
$stripped = preg_replace("/^\s*\w+\s*\(/", "", $content);
$stripped = preg_replace("/\)\s*$/", "", $stripped);
return w3_is_json($stripped);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.