note 74561 deleted from ref.array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: psbrogna at yahoo dot com 

----

Why is a deep copy function needed to move a sub array? I've just used the equality operator as in the code below.

<?php

$a= array(
    'a'=>'apple',
    'b'=>'banana',
    'c'=>'cherry',
    'subArray'=>array(
      'A'=>'APPLE',
      'B'=>'BANANA',
      'C'=>'CHERRY'
    )
  );

$a['copiedArray']= $a['subArray']; unset($a['subArray']);

var_dump($a);

?>

The above outputs the $a array with copiedArray being present and subArray gone. (php version: 4.4.0).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.