Re: [PHP] I'm doing something wrong....
In an associative array, there is no notion of the 'n-th' element. So AFAIK you can't do that. cheers, thalis On Wed, 15 May 2002, Robert Rothe wrote: > I've created an array. A very simple array that uses strings as keys. > > aname['one']=something; > aname['two']=something else; > > Isn't there any way to directly access the 'n'th element? > example: aname[0]? > > I've searched the group, but haven't found anything. Am I missing > something or can't this be done? > > TIA, > > Rob > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I'm doing something wrong....
When you create an array this way, no numeric indexes are assigned. Matthew Walker Senior Software Engineer ePliant Marketing -Original Message- From: Robert Rothe [mailto:[EMAIL PROTECTED]] Sent: Wednesday, May 15, 2002 2:35 PM To: [EMAIL PROTECTED] Subject: [PHP] I'm doing something wrong I've created an array. A very simple array that uses strings as keys. aname['one']=something; aname['two']=something else; Isn't there any way to directly access the 'n'th element? example: aname[0]? I've searched the group, but haven't found anything. Am I missing something or can't this be done? TIA, Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm doing something wrong....
Thanks. So the next() and prev() functions just traverse an array using some type of linked list? This is what precludes direct access to specific elements? "Thalis A. Kalfigopoulos" wrote: > > In an associative array, there is no notion of the 'n-th' element. So AFAIK you >can't do that. > > cheers, > thalis > > On Wed, 15 May 2002, Robert Rothe wrote: > > > I've created an array. A very simple array that uses strings as keys. > > > > aname['one']=something; > > aname['two']=something else; > > > > Isn't there any way to directly access the 'n'th element? > > example: aname[0]? > > > > I've searched the group, but haven't found anything. Am I missing > > something or can't this be done? > > > > TIA, > > > > Rob > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm doing something wrong....
There is no [0]...only ['one'] and ['two']... Look through the array functions, there may be a way to reassign the keys... ---John Holmes... - Original Message - From: "Robert Rothe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 15, 2002 4:35 PM Subject: [PHP] I'm doing something wrong > I've created an array. A very simple array that uses strings as keys. > > aname['one']=something; > aname['two']=something else; > > Isn't there any way to directly access the 'n'th element? > example: aname[0]? > > I've searched the group, but haven't found anything. Am I missing > something or can't this be done? > > TIA, > > Rob > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm doing something wrong....
http://www.php.net/manual/en/language.types.array.php An array in PHP is actually an ordered map. A map is a type that maps values to keys. we're not working with C where each array value is right next to each other in memory. it's an abstraction that does the job intelligently, but gives you a familiar-looking interface. -j Original Message Follows From: Robert Rothe <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: Re: [PHP] I'm doing something wrong Date: Wed, 15 May 2002 17:10:44 -0400 Thanks. So the next() and prev() functions just traverse an array using some type of linked list? This is what precludes direct access to specific elements? "Thalis A. Kalfigopoulos" wrote: > > In an associative array, there is no notion of the 'n-th' element. So AFAIK you can't do that. > > cheers, > thalis > > On Wed, 15 May 2002, Robert Rothe wrote: > > > I've created an array. A very simple array that uses strings as keys. > > > > aname['one']=something; > > aname['two']=something else; > > > > Isn't there any way to directly access the 'n'th element? > > example: aname[0]? > > > > I've searched the group, but haven't found anything. Am I missing > > something or can't this be done? > > > > TIA, > > > > Rob > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm doing something wrong....
yah, there's a function. (isn't there almost always?) http://www.php.net/manual/en/function.array-values.php it gives you a numerically indexed array of all the values in your current array, associative or not. -j Original Message Follows From: "1LT John W. Holmes" <[EMAIL PROTECTED]> Reply-To: "1LT John W. Holmes" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>, "Robert Rothe" <[EMAIL PROTECTED]> Subject: Re: [PHP] I'm doing something wrong Date: Wed, 15 May 2002 17:14:58 -0400 There is no [0]...only ['one'] and ['two']... Look through the array functions, there may be a way to reassign the keys... ---John Holmes... - Original Message - From: "Robert Rothe" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, May 15, 2002 4:35 PM Subject: [PHP] I'm doing something wrong > I've created an array. A very simple array that uses strings as keys. > > aname['one']=something; > aname['two']=something else; > > Isn't there any way to directly access the 'n'th element? > example: aname[0]? > > I've searched the group, but haven't found anything. Am I missing > something or can't this be done? > > TIA, > > Rob > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php _ Chat with friends online, try MSN Messenger: http://messenger.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] I'm doing something wrong....
Robert Rothe wrote: > Thanks. So the next() and prev() functions just traverse an array > some type of linked list? This is what precludes direct access to > specific elements? Yup, there is an internal position pointer in every array which are used by most array_ functions. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php