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:
>
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
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
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
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";
> >> }
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
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
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,
>> 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
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);
>>
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";
>>> }
>>
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 =
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
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
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]
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
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
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
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
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
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
21 matches
Mail list logo