Last active
August 29, 2015 14:19
-
-
Save mikestratton/eb3e7b16a2e193fe31cb to your computer and use it in GitHub Desktop.
identify the data type of a $value using gettype function
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 | |
// identify the data type of a $value using gettype function | |
// http://php.net/manual/en/function.gettype.php | |
$json = file_get_contents("http://mikestratton.net/temp/bigdatabox/tweetjson_RAW.php"); | |
$t_query = json_decode($json,true); | |
$name = $t_query ['statuses'][0]['user']['name']; | |
$screen = $t_query ['statuses'][0]['user']['screen_name']; | |
$text = $t_query ['statuses'][0]['text']; | |
$query = $t_query ['search_metadata']['query']; | |
$j_name = json_decode($name,true); | |
// test for data type | |
echo gettype($json), " (json) <br/>"; | |
echo gettype($t_query), " (t_query) <br/>"; | |
echo gettype($name), " (name) <br/>"; | |
echo gettype($screen), " (screen) <br/>"; | |
echo gettype($text), " (text) <br/>"; | |
echo gettype($query), " (query) <br/>"; | |
echo gettype($j_name), " (j_name) <br/><br/>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment