Re: how do i get a variable type? - not that simple
| From: | Rick St Jean | Date: | Sun, 18 Mar 2001 19:00:46 +0000 |
| Subject: | Re: how do i get a variable type? - not that simple | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-44449@lists.php.net to get a copy of this message | ||
I would right a function that would return a result and try an match within the different types.
if (isdate($a))
{
Dtype = date;
}
if (isdigit($a))
{
Dtype = int;
}
return (Dtype);
etc..
At 01:44 PM 3/18/01 -0500, phpman wrote:
No guys. that doesn't work. Take this code for example...
$a="3";
echo(gettype($a));
this returns string
i need to find it as an integer or real or float for the sql. which by the
way is MySQL.
thank you for responding, but I already know that gettype and all the other
is_* don't work for this.
""phpman"" <info@graphicon.nu> wrote in message
news:99132e$ol8$1@toye.p.sourceforge.net...
hello all,
let's say i have this:
$a="varone=hello world|vartwo=2.44|varthree=100|";
now i do this:
$b=explode('|',$a);
$z=count($b);
for ($x=0;$x<$z;$x++) {
$tmp=explode('=',$b[$x]);
....
and i want to find out if $tmp[1] is a string or an integer (that's
really
all I need to determine so i can put
together an SQL statement that puts single quotes around strings and none
around integers). Obviously
i won't know at design time all of the variables and their values. Thank
you.
-dave
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net
##########################################################
# Rick St Jean,
# rstjean@internet.look.ca
# President of Design Shark,
# http://www.designshark.com/
# Quick Contact: http://www.designshark.com/messaging.ihtml
# Tel: 905-684-2952
##########################################################