Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What Types of Data Can Be Used as Array Keys
What Types of Data Can Be Used as Array Keys? - PHP Script Tips - Understanding PHP Arrays and Their Basic Operations
✍: FYIcenter.com
Two types of data can be used as array keys: string and integer. When a string is used as a key and the string represent an integer, PHP will convert the string into a integer and use it as the key. Here is a PHP script on different types of keys:
<?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed["Two"] = "Java"; $mixed["3"] = "C+"; $mixed[""] = "Basic"; print("Array with mixed keys:\n"); print_r($mixed); print("\$mixed[3] = ".$mixed[3]."\n"); print("\$mixed[\"3\"] = ".$mixed["3"]."\n"); print("\$mixed[\"\"] = ".$mixed[""]."\n"); ?>
This script will print:
Array with mixed keys: Array ( [Zero] => PHP [1] => Perl [Two] => Java [3] => C+ [] => Basic ) $mixed[3] = C+ $mixed["3"] = C+ $mixed[""] = Basic
Note that an empty string can also be used as a key.
2007-04-14, 4586👍, 0💬
Popular Posts:
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...
What is shadowing ? When two elements in a program have same name, one of them can hide and shadow t...
Which bit wise operator is suitable for checking whether a particular bit is on or off? The bitwise ...
Can one change the mouse pointer in Forms? The SET_APPLICATION_PROPERTY build-in in Oracle Forms all...
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ? If a ta...