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:
Can You Add Values to an Array without a Key
Can You Add Values to an Array without a Key? - PHP Script Tips - Understanding PHP Arrays and Their Basic Operations
✍: FYIcenter.com
Can You Add Values to an Array with a Key? The answer is yes and no. The answer is yes, because you can add values without specifying any keys. The answer is no, because PHP will add a default integer key for you if you are not specifying a key. PHP follows these rules to assign you the default keys:
Here is a PHP example script:
<?php $mixed = array(); $mixed["Zero"] = "PHP"; $mixed[1] = "Perl"; $mixed["Two"] = "Java"; $mixed["3"] = "C+"; $mixed[""] = "Basic"; $mixed[] = "Pascal"; $mixed[] = "FORTRAN"; print("Array with default keys:\n"); print_r($mixed); ?>
This script will print:
Array with default keys: Array ( [Zero] => PHP [1] => Perl [Two] => Java [3] => C+ [] => Basic [4] => Pascal [5] => FORTRAN )
2007-04-20, 4971👍, 0💬
Popular Posts:
What will be printed as the result of the operation below: main() { int x=5; printf("%d,%d,%d\n",x,x. ..
when should the volatile modifier be used? The volatile modifier is a directive to the compiler's op...
What exactly happens when ASPX page is requested from Browser? Note: - Here the interviewer is expec...
What is XSLT? XSLT is a rule based language used to transform XML documents in to other file formats...
How you will enable front-end validation based on the xml in validation.xml? The <html:javascr...