note 74664 deleted from ref.var by colder

From: Date: Mon, 23 Apr 2007 05:46:01 +0000
Subject: note 74664 deleted from ref.var by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125788@lists.php.net to get a copy of this message
Note Submitter: nobodyspecial Reason: useless ---- Here's a simple way of telling you what the variable is, like if it's string, integer, etc.: <?php if(!function_exists("gettype_array")) { function gettype_array($var) { $types = array("array","binary","bool","buffer", "callable","double","float","int", "integer","long","null","numeric", "object","real","resource","scalar", "string","unicode"); $i=0; $_call = ""; $return = array(); foreach($types as $type) { $_call = "is_".$type; if(@function_exists($_call)) { if($_call($var)) { $return[$i] = $type; $i += 1; } } $_call = ""; } return $return; } } ?> To demo: <?php $test = 1; $results = gettype_array($test); print_r($results); echo "\n\n"."Result #2 is a ".$results[2]."!"; ?> The results (depending on PHP version): Array ( [0] => int [1] => integer [2] => long [3] => numeric [4] => scalar ) Result #2 is a long!

« previous php.notes (#125788) next »