note 62042 added to function.array-keys
| From: | jochem at osu1 dot php dot net | Date: | Sat, 18 Feb 2006 00:13:35 +0000 |
| Subject: | note 62042 added to function.array-keys | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103952@lists.php.net to get a copy of this message | ||
might be worth noting in the docs that not all associative (string) keys are a like, output of the
follow bit of code demonstrates - might be a handy introduction to automatic typecasting in php for
some people (and save a few headaches):
$r = array("0"=>"0","1"=>"1",""
=>"2"," "=>"3");
echo 'how php sees this array:
array("0"=>"0","1"=>"1",""
=>"2"," "=>"3")',"\n-----------\n";
var_dump($r); print_r($r); var_export($r);
echo "\n-----------\n",'var_dump("0","1","","
") = ',"\n-----------\n";
var_dump("0","1",""," ");
OUTPUTS:
how php sees this array:
array("0"=>"0","1"=>"1",""
=>"2"," "=>"3")
-----------
array(4) {
[0]=>
string(1) "0"
[1]=>
string(1) "1"
[""]=>
string(1) "2"
[" "]=>
string(1) "3"
}
Array
(
[0] => 0
[1] => 1
[] => 2
[ ] => 3
)
array (
0 => '0',
1 => '1',
'' => '2',
' ' => '3',
)
-----------
var_dump("0","1",""," ") =
-----------
string(1) "0"
string(1) "1"
string(0) ""
string(1) " "
----
Server IP: 194.109.193.119
Probable Submitter: 87.211.15.129
----
Manual Page -- http://www.php.net/manual/en/function.array-keys.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+62042
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62042&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+62042&report=yes
Search -- http://master.php.net/manage/user-notes.php