Try this

function get_type($var)
{
    if(is_object($var))
        return get_class($var);
    if(is_null($var))
        return 'null';
    if(is_string($var))
        return 'string';
    if(is_array($var))
        return 'array';
    if(is_int($var))
        return 'integer';
    if(is_bool($var))
        return 'boolean';
    if(is_float($var))
        return 'float';
    if(is_resource($var))
        return 'resource';
    //throw new NotImplementedException();
    return 'unknown';
}



On Fri, Mar 15, 2013 at 3:28 PM, Karim Geiger <gei...@b1-systems.de> wrote:

> Hi,
>
> On Fri, 2013-03-15 at 09:55 +0000, Kevin Peterson wrote:
> > Have two questions -
> > 1. How to find type of a variable in PHP.
> > 2. How to find the type of an array in PHP.
> >
> > Please help.
> >
>
> Use this:
> http://php.net/manual/en/function.gettype.php
>
> Regards
>
> Karim
>
> --
> Karim Geiger
>
> B1 Systems GmbH
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
>

Reply via email to