Page 1 of 1
assigning initial values to multi-dimentional array
Posted: Thu Jun 07, 2012 9:53 pm
by wvoyance
I know how to assign initial value to single dimensional array by
$sql_data_array = array('name' => 'abc', 'products_status' => '1');
what should I do for two-dimensional array? suppose 'name' has a second dimension 'ch' 'en' 'fr'?
Re: assigning initial values to multi-dimentional array
Posted: Fri Jun 08, 2012 12:23 am
by requinix
Make name's value be another array.
Code: Select all
$sql_data_array = array('name' => array('ch', 'en', 'fr'), 'products_status' => '1');
Re: assigning initial values to multi-dimentional array
Posted: Fri Jun 08, 2012 1:51 am
by wvoyance
Is there still other ways to write it?
I know I can write it element by element as
$sql_data_array ['name']['ch'] = 'abc';
$sql_data_array ['name']['en'] = 'def';
Re: assigning initial values to multi-dimentional array
Posted: Sat Jun 09, 2012 12:06 am
by requinix
Code: Select all
$sql_data_array = array('name' => array(), 'products_status' => '1');
Now $sql_data_array["name"] is an array which means you can do any array thing you want to it. Including adding items.
Re: assigning initial values to multi-dimentional array
Posted: Mon Jun 11, 2012 9:44 am
by wvoyance
who do you adore? requinix?
Re: assigning initial values to multi-dimentional array
Posted: Mon Jun 11, 2012 12:54 pm
by requinix
wvoyance wrote:who do you adore? requinix?
Just a spammer. Ignore it.