[PHP] array key's: which is correct?

2010-06-08 Thread Tanel Tammik
Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Br Tanel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:12:42PM +0300, Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; If the index for (integer) 3, the first example is correct. If the index is (string) '3', the second example is correct. $i = 7; $array[$i] = '';

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:12 +0300, Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Br Tanel The two indexes are equivalent, although I reckon the integer one will give better

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings
Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Sometimes it is good to illustrate the correct answer: ?php $array = array ( '1' = '1', '2' = '2', 'three' = 'three', '4.0'

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 09:38 -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Sometimes it is good to illustrate the correct answer: ?php

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = ''; Sometimes it is good to illustrate the correct answer: ?php $array = array

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3'] = ''; $i = 7; $array[$i] = ''; or $array[$i] = '';

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which one is correct or better? $array[3] = ''; or $array['3']

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi, which

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Peter Lind
On 8 June 2010 16:53, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Ashley Sheridan
On Tue, 2010-06-08 at 17:11 +0200, Peter Lind wrote: On 8 June 2010 16:53, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 16:44 +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400,

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Paul M Foster
On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik wrote: Hi,

Re: [PHP] array key's: which is correct?

2010-06-08 Thread Robert Cummings
Paul M Foster wrote: On Tue, Jun 08, 2010 at 04:44:53PM +0200, Peter Lind wrote: On 8 June 2010 16:38, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Tue, 2010-06-08 at 10:35 -0400, Paul M Foster wrote: On Tue, Jun 08, 2010 at 09:38:58AM -0400, Robert Cummings wrote: Tanel Tammik