[RESOLVED] Declaring an empty array of 4 element (without giving any value yet)
Hi!
I have an object that has a property array containing 4 elements, but without any value yet. So if I call array[0] I dont want to have an undefined index error...
is there anything like array{4} or something like that, that would declare
array[0]
array[1]
array[2]
array[3] ?????????
Re: Declaring an empty array of 4 element (without giving any value yet)
You could create an array with null values in them
PHP Code:
$your_array = array(0,0,0,0);
$your_array[0] = "some value";
$your_array[1] = 12.13;
$your_array[2] = 123456;
$your_array[3] = 'valuesasd';
Re: Declaring an empty array of 4 element (without giving any value yet)
ok thanks, I had found a work around similar to this
PHP Code:
array("","","","");
but wanted to make sure i was not missing somehing, thanks john!
Re: Declaring an empty array of 4 element (without giving any value yet)
Well as PHP is dynamically typed doesnt really matter what type it is.
Although lately i have been really lazy and just turned off warning in my scripts :eek2:
Re: Declaring an empty array of 4 element (without giving any value yet)
Quote:
Originally Posted by john tindell
Well as PHP is dynamically typed doesnt really matter what type it is.
Although lately i have been really lazy and just turned off warning in my scripts :eek2:
hahaha