PHP: is it posible to create two array with same name with two different dimension


Codeigniter PHP  I want to create two arrays with same name $name

$name = array();  $name[] = 'value';  $name[][] = 'value';  

is this possible in any way because I am facing problem doing this?...


What you're attempting to do is possible but you need to go about it in a slightly different way.

$name[] = ['value'];  

Keep in mind that by doing this you're going to face the problem of accessing the array. You're probably better setting a key to make it easier.

$name['test'] = ['value'];  

You can then append further values to your array quite easily.

$name['test'][] = 'second value';  

Yes its possible just use another index like below :

$name = array();  $name[] = 'value';  $name[]['array_2'] = 'value';