programmer programmer - 1 year ago 56
PHP Question

How can i assign an array to another variable in php?

i have defined an array in php

$letters = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","W","V","X","Y","Z");

Then i try to assign the array to a new variable that is going to be an array and i do:

$new_array = array();
$new_array = $letters;

But it's not working, why?

Answer Source

You can just do

$new_array = $letters;

You don't have to specify the type because it is implied.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download