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, 5410👍, 0💬
Popular Posts:
How To Write a Minimum Atom 1.0 Feed File? - RSS FAQs - Atom Feed Introduction and File Generation I...
How To Retrieve Input Values for Checkboxes Properly? - PHP Script Tips - Processing Web Forms If mu...
How To Call a Sub Procedure? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and Functions To...
Describe different elements in Static Chart diagrams ? Package: - It logically groups element of a U...
I have 5 questions please give me the answer ,explanation,suggestions if any?? what is PMP(project m...