http://bugs.php.net/bugs.php?id=8409
| From: | Cynic | Date: | Sat, 06 Jan 2001 03:58:53 +0000 |
| Subject: | http://bugs.php.net/bugs.php?id=8409 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-43120@lists.php.net to get a copy of this message | ||
A note to bug #8409:
the more I know about arrays in PHP, the more I feel like
PHP is typed _too_ loosely when it comes to arrays.
Output of
$a = array( '1.10' , '1.12' ) ;
echo in_array( '1.1' , $a ) ? "loose match\n" : "loose miss\n" ;
echo in_array( '1.1' , $a , true ) ? "strict match\n" : "strict
miss\n" ;
is
loose match
strict miss
however
echo "1.0" == "1.10" ? "match\n" : "miss\n" ;
evals to false (e.g. echoes "miss").
Add the inability to have a numeric string as an array key,
(is there a reason why
var_dump( array( "11"=>'aaa' , 'bbb' , 'ccc' ) ) ;
produces
array(3) { [11]=> string(3) "aaa" [12]=> string(3) "bbb" [13]=>
string(3) "ccc" }
? The "11" is a string, not an int, if I wanted it to be an int,
I would cast it)
troubles with sorting functions, extract() refusing to extract
a numerically indexed array even with PREFIX_ALL, and an
aversion to arrays builds up.
Methinks (YMMV) implicit conversions were meant to make things
easier, not complicated, let alone impossible.
Can arrays in PHP change a bit, or are they carved in stone
yet? Is, for example, change to extract() so that
$a = array( 'aaa' , 'bbb' , 'ccc' ) ;
extract( $a , EXTR_PREFIX_ALL , 'prefix' ) ;
creates $prefix_1 , $prefix_2, and $prefix_3 in current scope?
And what about changing it so that it returns? I'd like to see
extract() return maybe number of variables it created.
Discussion is welcome.
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz