Re: [nyphp-talk] Accessing First Element of Array

2007-08-27 Thread Michael B Allen
On 8/27/07, Ken Downs <[EMAIL PROTECTED]> wrote: > "Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > > > > > > > > Um, you could, uh, write a function called array_first() that does the > > > reset() and then calls each()? Then maybe even calls reset() again? > Then > > > you could, like, mayb

Re: [nyphp-talk] Accessing First Element of Array

2007-08-27 Thread Ken Downs
"Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > > > > Um, you could, uh, write a function called array_first() that does the > > reset() and then calls each()? Then maybe even calls reset() again? Then > > you could, like, maybe, only use this function and not make arbitrary use of > > each()

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > "Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > > "Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > > > > > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > > > > look at "each", it

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Ken Downs
"Michael B Allen" <[EMAIL PROTECTED]> wrote: > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > "Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > > > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > > > look at "each", it is a (mostly deprecate) form of array iteration. The > > > > sam

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > "Michael B Allen" <[EMAIL PROTECTED]> wrote: > > > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > > look at "each", it is a (mostly deprecate) form of array iteration. The > > > sample code in the PHP manual will show exactly what you are

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Jon Baer
Hmmm I dunno, if that was more towards "what was the way to access the first element of a hash?" I would say ok, but Im still convinced most would see an "array" as an object numerically indexed. But current() it is :-) Time to rewrite all those PHP books ... On a side note to why the examp

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Ken Downs
"Michael B Allen" <[EMAIL PROTECTED]> wrote: > On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > > look at "each", it is a (mostly deprecate) form of array iteration. The > > sample code in the PHP manual will show exactly what you are looking for. > > But again that modifies the array (it adva

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Mark Armendariz
Paul M Jones wrote: On Aug 26, 2007, at 7:54 PM, Jon Baer wrote: Is it anything that $array[0] would not be able to get access to? The function `current($array)` should do the trick. Make sure you do so before trying to loop through the array or anything. ;-) Or just reset before using it.

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
On 8/26/07, Dell Sala <[EMAIL PROTECTED]> wrote: > On Aug 26, 2007, at 9:08 PM, Michael B Allen wrote: > > > On 8/26/07, Jon Baer <[EMAIL PROTECTED]> wrote: > >> Is it anything that $array[0] would not be able to get access to? > > > > Nope. The 0 element is not necessarily first. Consider the > >

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Dell Sala
On Aug 26, 2007, at 9:08 PM, Michael B Allen wrote: On 8/26/07, Jon Baer <[EMAIL PROTECTED]> wrote: Is it anything that $array[0] would not be able to get access to? Nope. The 0 element is not necessarily first. Consider the following example: $array = array(); $array['first'] = 'foo'; $a

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
On 8/26/07, Jon Baer <[EMAIL PROTECTED]> wrote: > Is it anything that $array[0] would not be able to get access to? Hi Jon, Nope. The 0 element is not necessarily first. Consider the following example: $array = array(); $array['first'] = 'foo'; $array[] = 'bar'; $ ./t.php Array ( [first] =>

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Paul M Jones
On Aug 26, 2007, at 7:54 PM, Jon Baer wrote: Is it anything that $array[0] would not be able to get access to? The function `current($array)` should do the trick. Make sure you do so before trying to loop through the array or anything. ;-) -- Paul M. Jones

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
On 8/26/07, Ken Downs <[EMAIL PROTECTED]> wrote: > look at "each", it is a (mostly deprecate) form of array iteration. The > sample code in the PHP manual will show exactly what you are looking for. But again that modifies the array (it advances the cursor). I guess I can write something myself:

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Jon Baer
Is it anything that $array[0] would not be able to get access to? - Jon On Aug 26, 2007, at 8:45 PM, Michael B Allen wrote: Hi, How do you access the first element of an array? I'm looking for something like array_shift but without modifying the array. Mike __

Re: [nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Ken Downs
look at "each", it is a (mostly deprecate) form of array iteration.  The sample code in the PHP manual will show exactly what you are looking for."Michael B Allen" <[EMAIL PROTECTED]> wrote: > Hi, > > How do you access the first element of an array? I'm looking for > something like array_shift bu

[nyphp-talk] Accessing First Element of Array

2007-08-26 Thread Michael B Allen
Hi, How do you access the first element of an array? I'm looking for something like array_shift but without modifying the array. Mike ___ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations