Re: [nyphp-talk] string function

2008-07-04 Thread Brian D.
Note: This response is more or less tongue in cheek, and is not meant to be taken seriously. string(5) "98.8$" ["yuhj78t"]=> string(5) "32.6$" ["tris78y"]=> string(7) "459.78$" } On Wed, Jul 2, 2008 at 5:35 PM, chad qian <[EMAIL PROTECTED]> wrote: > An unknown string,its format is: >

Re: [nyphp-talk] string function

2008-07-03 Thread Kristina Anderson
If rewriting this function saves me .0001 milliseconds of processing time, can I spend that time watching baseball instead of writing code?? :) Kristina > At 12:06 PM -0400 7/3/08, John Campbell wrote: > >On Thu, Jul 3, 2008 at 11:11 AM, Urb LeJeune <[EMAIL PROTECTED]> wrote: > >> Is this the

Re: [nyphp-talk] string function

2008-07-03 Thread Michael Southwell
Brian O'Connor wrote: >> $p = explode('|',$y); >> for($i=0,$c = count($p);$i<$c;) { >> echo $p[$i++],' ', $p[$i++], "\n"; >> } > > I believe this will miss the first element of $p; you need instead: > > for ( $i = -1, $c = count( $p ); $i < $c; ) { If

Re: [nyphp-talk] string function

2008-07-03 Thread Michael Southwell
John Campbell wrote: > If you start from -1, then you would need to use ++$i rather than $i++ aha, the first *really good* illustration of the difference that I have ever seen ;-) -- = Michael Southwell Vice President, Education NYPHP TRAINING: http://nyphp.com/Training/Inde

Re: [nyphp-talk] string function

2008-07-03 Thread Brian O'Connor
On Thu, Jul 3, 2008 at 1:32 PM, John Campbell <[EMAIL PROTECTED]> wrote: > On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell > <[EMAIL PROTECTED]> wrote: > > John Campbell wrote: > >> > >> $p = explode('|',$y); > >> for($i=0,$c = count($p);$i<$c;) { > >> echo $p[$i++],' ', $p[$i++], "\n"; > >> }

Re: [nyphp-talk] string function

2008-07-03 Thread tedd
At 12:06 PM -0400 7/3/08, John Campbell wrote: On Thu, Jul 3, 2008 at 11:11 AM, Urb LeJeune <[EMAIL PROTECTED]> wrote: Is this the same thing that you are trying to accomplish with the for loop? Yes but increments (or decrements) are executed much more efficiently than additions. This is

Re: [nyphp-talk] string function

2008-07-03 Thread Brian O'Connor
No. $i++ returns the value of $i, then increments it. On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell < [EMAIL PROTECTED]> wrote: > John Campbell wrote: > >> $p = explode('|',$y); >> for($i=0,$c = count($p);$i<$c;) { >> echo $p[$i++],' ', $p[$i++], "\n"; >> } >> > > I believe this will miss t

Re: [nyphp-talk] string function

2008-07-03 Thread John Campbell
On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell <[EMAIL PROTECTED]> wrote: > John Campbell wrote: >> >> $p = explode('|',$y); >> for($i=0,$c = count($p);$i<$c;) { >> echo $p[$i++],' ', $p[$i++], "\n"; >> } > > I believe this will miss the first element of $p; you need instead: > > for ( $i = -1,

Re: [nyphp-talk] string function

2008-07-03 Thread John Campbell
>> and aren't you glad this guy asked this question? > > No. > Grr... I misread what you wrote... I thought you wrote, "are you the guy that asked the question?" ... I need a vacation. ___ New York PHP Community Talk Mailing List http://lists.nyphp.o

Re: [nyphp-talk] string function

2008-07-03 Thread John Campbell
On Thu, Jul 3, 2008 at 1:22 PM, John Campbell <[EMAIL PROTECTED]> wrote: > On Thu, Jul 3, 2008 at 1:10 PM, David Mintz <[EMAIL PROTECTED]> wrote: >> >> >> On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell >> <[EMAIL PROTECTED]> wrote: >>> >>> John Campbell wrote: $p = explode('|',$y); >>

Re: [nyphp-talk] string function

2008-07-03 Thread John Campbell
On Thu, Jul 3, 2008 at 1:10 PM, David Mintz <[EMAIL PROTECTED]> wrote: > > > On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell > <[EMAIL PROTECTED]> wrote: >> >> John Campbell wrote: >>> >>> $p = explode('|',$y); >>> for($i=0,$c = count($p);$i<$c;) { >>> echo $p[$i++],' ', $p[$i++], "\n"; >>> } >>

Re: [nyphp-talk] string function

2008-07-03 Thread David Mintz
On Thu, Jul 3, 2008 at 12:45 PM, Michael Southwell < [EMAIL PROTECTED]> wrote: > John Campbell wrote: > >> $p = explode('|',$y); >> for($i=0,$c = count($p);$i<$c;) { >> echo $p[$i++],' ', $p[$i++], "\n"; >> } >> > > I believe this will miss the first element of $p; you need instead: > > for ( $i =

Re: [nyphp-talk] string function

2008-07-03 Thread Michael Southwell
John Campbell wrote: $p = explode('|',$y); for($i=0,$c = count($p);$i<$c;) { echo $p[$i++],' ', $p[$i++], "\n"; } I believe this will miss the first element of $p; you need instead: for ( $i = -1, $c = count( $p ); $i < $c; ) { -- = Michael Southwell Vice President, Education

Re: [nyphp-talk] string function

2008-07-03 Thread John Campbell
On Thu, Jul 3, 2008 at 11:11 AM, Urb LeJeune <[EMAIL PROTECTED]> wrote: > Is this the same thing that you are trying to accomplish with the > for loop? > > Yes but increments (or decrements) are executed much more efficiently than > additions. This is wrong for three reasons: 1) 4 ++ increments is

Re: [nyphp-talk] string function

2008-07-03 Thread Rolan Yang
Dan Cech wrote: Urb LeJeune wrote: An unknown string,its format is: y="tnk81|98.8$|yuhj78t|32.6$|tris78y|459.78$|." .. You could write this a little more simply as: $parts = explode('|',$y); $cnt = count($parts); for ($i = 0;$i < $cnt - 1;$i += 2) { echo $parts[$i] .' '. $parts[$i+1]

Re: [nyphp-talk] string function

2008-07-03 Thread Urb LeJeune
Is this the same thing that you are trying to accomplish with the for loop? Yes but increments (or decrements) are executed much more efficiently than additions. Urb for($Sub1=0,$Sub2=1;$Sub2<=$Count;) { echo "$Parts[$Sub1] $Parts[Sub2]\n"; $Sub1+=2; $Sub2+=2; } I just want to k

Re: [nyphp-talk] string function

2008-07-03 Thread Ken Robinson
Quoting Urb LeJeune <[EMAIL PROTECTED]>: An unknown string,its format is: y="tnk81|98.8$|yuhj78t|32.6$|tris78y|459.78$|." list($Parts) = explode("|",$y); $Count = count($Parts); for($Sub1=0,$Sub2=1;$Sub2<=$Count;$Sub1++,$Sub1++,$Sub2++,$Sub2++) echo "$Parts[$Sub1] $Parts[Sub2]\n"; T

Re: [nyphp-talk] string function

2008-07-03 Thread Néstor
Is this the same thing that you are trying to accomplish with the for loop? for($Sub1=0,$Sub2=1;$Sub2<=$Count;) { echo "$Parts[$Sub1] $Parts[Sub2]\n"; $Sub1+=2; $Sub2+=2; } I just want to know if I read it correctly. Thanks, Nestor :-) On Thu, Jul 3, 2008 at 7:36 AM, Urb LeJeune <[EMAI

Re: [nyphp-talk] string function

2008-07-03 Thread Dan Cech
Urb LeJeune wrote: An unknown string,its format is: y="tnk81|98.8$|yuhj78t|32.6$|tris78y|459.78$|." list($Parts) = explode("|",$y); $Count = count($Parts); for($Sub1=0,$Sub2=1;$Sub2<=$Count;$Sub1++,$Sub1++,$Sub2++,$Sub2++) echo "$Parts[$Sub1] $Parts[Sub2]\n"; You could write this a litt

Re: [nyphp-talk] string function

2008-07-03 Thread Urb LeJeune
An unknown string,its format is: y="tnk81|98.8$|yuhj78t|32.6$|tris78y|459.78$|." list($Parts) = explode("|",$y); $Count = count($Parts); for($Sub1=0,$Sub2=1;$Sub2<=$Count;$Sub1++,$Sub1++,$Sub2++,$Sub2++) echo "$Parts[$Sub1] $Parts[Sub2]\n"; Not tested. Urb Dr. Urban A. LeJeune, Presi

Re: [nyphp-talk] string function

2008-07-02 Thread bzcoder
chad qian wrote: How to program php to get this output?String is divided by "|". explode. http://us3.php.net/manual/en/function.explode.php ___ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 P