Hello,
Can I initialize the array in PHP as shown below.
$myarray=array();
this is because I don't know the exact values at the time of initialization, the values will be filled from the database in the while loop.
Thanks
Regards
PHP array
Moderator: General Moderators
Re: PHP array
Yes
Re: PHP array
Yes, you can initialise an array like that:
$a = array( );
Afterwards you can add values by using the following code:
$a[ ] = value;
Or if you are using a "for" loop, you can do it like so:
$a[$i] or $a[++$i]
Hope this helps.
P.S. Checkout this link, it may help with some more functions: http://www.w3schools.com/php/php_ref_array.asp
$a = array( );
Afterwards you can add values by using the following code:
$a[ ] = value;
Or if you are using a "for" loop, you can do it like so:
$a[$i] or $a[++$i]
Hope this helps.
P.S. Checkout this link, it may help with some more functions: http://www.w3schools.com/php/php_ref_array.asp