NYCPHP Meetup

NYPHP.org

[nycphp-talk] Casting and list

Hans Zaunere hans at newyorkphp.com
Mon Dec 22 10:39:37 EST 2003


Good morning,

I'm using list()  (http://us4.php.net/list) to put the values from a
mysql_fetch_row() call into separate variables - yes, it's trivial.

However, I need some the elements to be casted to ints.  I'm aware of
the various workarounds, but what I'd really like to do is:

list( (int) $id,$name, (int) $somenumber) = mysql_fetch_row($result);

Of course, this throws a parse error.  Is anyone aware of any clever
tricks that keeps a nearly identical syntax?  Or, maybe this could be a
feature request (although it won't do me any good today :)  What I'm
doing now is:

list($id,$name,$somenumber) = mysql_fetch_row($result);

$id = (int) $id;
$somenumber = (int) $somenumber;


But I just don't like that, especially with tons of columns from the DB,
big loops, etc...

Thanks,

H



More information about the talk mailing list