On Sat, 2009-05-09 at 20:02 +0530, kranthi wrote:
> thanks for the reply... just happened to see http://php.net/ternary
> which explains the above result
> 
> i want to explicitly type cast all the numbers passed via post (by
> default they are strings)
> is_numeric() is a option, but it will not be possible to differentiate
> between int and float.
> 
> $_POST['month'] !== (string)(int)$_POST['month']
> this is exactly what i want... but wont this take up memory when used
> with array_walk_recursive() ?

Just add the value to 0 and PHP will do the juggling for you:

<?php

$_POST = array( '1', '100', '100.1', '100.123' );

foreach( $_POST as $value )
{
    $value = 0 + $value;
    
    echo 'Value: ';
    var_dump( $value );
}

?>

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to