php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #2284 type conversion in list()
Submitted: 1999-09-12 15:24 UTC Modified: 2000-08-17 10:38 UTC
From: tsf at post dot cz Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.12 OS: linux
Private report: No CVE-ID: None
 [1999-09-12 15:24 UTC] tsf at post dot cz
list is a great construct that can save you many lines
of code.  however, i often need to do user conversions
and then the magic of list() is gone... could you
possibly add a syntax extension allowing commands like

list((int)$foo, (int)$bar) = $array_of_foo_and_bar;

or is it a nonsense? :)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-09-21 13:22 UTC] tsf at post dot cz
and thinking about it more now... how about empty variables
(like in prolog?)

list($a, _, $c) = $myarray;

the underscore is probably not o.k. here (it would collide 
with a constant named _ , i guess) but it should do as an
example. I used it  because that is what is used in
Prolog. So those of you familiar with that language should 
know what i mean.
 [1999-09-21 13:54 UTC] rasmus at cvs dot php dot net
list($a,,$c) = $myarray();
 [2000-08-17 10:38 UTC] hholzgra@php.net
works in 3.0.16 and 4
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 14:01:32 2024 UTC