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 Copy an Array
Can You Copy an Array? - PHP Script Tips - Understanding PHP Arrays and Their Basic Operations
✍: FYIcenter.com
You can create a new array by copying an existing array using the assignment statement. Note that the new array is not a reference to the old array. If you want a reference variable pointing to the old array, you can use the reference operator "&". Here is a PHP script on how to copy an array:
<?php $oldArray = array("Zero"=>"PHP", "One"=>"Perl", "Two"=>"Java"); $newArray = $oldArray; $refArray = &$oldArray; $newArray["One"] = "Python"; $refArray["Two"] = "C#"; print("\$newArray[\"One\"] = ".$newArray["One"]."\n"); print("\$oldArray[\"One\"] = ".$oldArray["One"]."\n"); print("\$refArray[\"Two\"] = ".$refArray["Two"]."\n"); print("\$oldArray[\"Two\"] = ".$oldArray["Two"]."\n"); ?>
This script will print:
$newArray["One"] = Python $oldArray["One"] = Perl $refArray["Two"] = C# $oldArray["Two"] = C#
2007-04-20, 4968👍, 0💬
Popular Posts:
How To Avoid the Undefined Index Error? - PHP Script Tips - Processing Web Forms If you don't want y...
Regarding C Coding Given: Line in file Contents 30 int * someIDs, theFirst, *r; 110 someIDs =GetSome...
What Does a HTML Document Look Like? A HTML document is a normal text file with predefined tags mixe...
What exactly happens when ASPX page is requested from Browser? Note: - Here the interviewer is expec...
How Is the Width a Parent Element Related to Child Elements? - CSS Tutorials - Understanding Multipl...