From: Php Developer on 2 Apr 2010 19:52 Hi all, I want to be able to have an array of elements of different types. As an example: the first element is a boolean, the second is an integer, and the thirs is a string. In php there is no typing, i'm just wondering if there is a way to have that, it would be a lot better than having an array of strings and have to convert each element. Thank you __________________________________________________________________ The new Internet Explorer® 8 - Faster, safer, easier. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
From: Nathan Rixham on 2 Apr 2010 20:12 Php Developer wrote: > Hi all, > > I want to be able to have an array of elements of different types. As an example: the first element is a boolean, the second is an integer, and the thirs is a string. > > In php there is no typing, i'm just wondering if there is a way to have that, it would be a lot better than having an array of strings and have to convert each element. > var_dump( array( true , 12 , "php already does this" ) ); array(3) { [0]=> bool(true) [1]=> int(12) [2]=> string(21) "php already does this" } :)
From: Nilesh Govindarajan on 2 Apr 2010 22:12 On 04/03/10 05:42, Nathan Rixham wrote: > Php Developer wrote: >> Hi all, >> >> I want to be able to have an array of elements of different types. As an example: the first element is a boolean, the second is an integer, and the thirs is a string. >> >> In php there is no typing, i'm just wondering if there is a way to have that, it would be a lot better than having an array of strings and have to convert each element. >> > > var_dump( array( true , 12 , "php already does this" ) ); > > array(3) { > [0]=> bool(true) > [1]=> int(12) > [2]=> string(21) "php already does this" > } > > :) > Yeah. But this feature of PHP is a boon if used carefully and a curse if careless. You can get AMAZING results if you're not careful to check the data types ;) -- Nilesh Govindarajan Site & Server Administrator www.itech7.com मेरा भारत महान ! मम भारत: महत्तम भवतु !
From: "Peter Pei" on 3 Apr 2010 10:57 >> >> var_dump( array( true , 12 , "php already does this" ) ); >> >> array(3) { >> [0]=> bool(true) >> [1]=> int(12) >> [2]=> string(21) "php already does this" >> } >> >> :) >> > > Yeah. But this feature of PHP is a boon if used carefully and a curse if > careless. You can get AMAZING results if you're not careful to check the > data types ;) > And that's why language like C# and java supports <> to restrict the type of data a collection can hold. -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
|
Pages: 1 Prev: SimpleXMLElement and gb2312 or big5 Next: GetElementByClass? |