Re: [PHP] what to use instead of foreach

2009-04-14 Thread PJ
Mark Kelly wrote: > Hi Phil. > > On Monday 13 April 2009, PJ wrote: > >> Thanks for the suggestion, Mark. I've already experimented with count; >> you're close, but there is still a small glitch and that's in count(); >> foreach doesn't give a damn about count so you can't use that - it is >> re

Re: [PHP] what to use instead of foreach

2009-04-14 Thread Mark Kelly
Hi Phil. On Monday 13 April 2009, PJ wrote: > Thanks for the suggestion, Mark. I've already experimented with count; > you're close, but there is still a small glitch and that's in count(); > foreach doesn't give a damn about count so you can't use that - it is > reset once inside the foreach loop

Re: [PHP] what to use instead of foreach

2009-04-14 Thread PJ
will help to validate the route you are trying to follow. > > Best wishes > Leon > > -Original Message- > From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] > Sent: 14 April 2009 05:45 PM > To: PJ > Cc: Leon du Plessis; php-general@lists.php.net > Subject: Re:

RE: [PHP] what to use instead of foreach

2009-04-14 Thread Leon du Plessis
. Best wishes Leon -Original Message- From: Jan G.B. [mailto:ro0ot.w...@googlemail.com] Sent: 14 April 2009 05:45 PM To: PJ Cc: Leon du Plessis; php-general@lists.php.net Subject: Re: [PHP] what to use instead of foreach 2009/4/13 PJ : > I have already tried with several count and

Re: [PHP] what to use instead of foreach

2009-04-14 Thread Jan G.B.
2009/4/13 PJ : > I have already tried with several count and for schemes. None work > because foreach ignores any counters once in the loop. Also, this > foreach is nested within another foreach; don't know if that affects > anything. Have you heard of while()? You can use it in combination with

Re: [PHP] what to use instead of foreach

2009-04-13 Thread Nitsan Bin-Nun
the fixing, > > but I am > > sure you get the general idea. > > > > Best wishes..Leon > > > > -Original Message----- > > From: Leon du Plessis [mailto:l...@dsgnit.com] > > Sent: 13 April 2009 06:48 PM > > To: 'PJ' > > Cc: php

Re: [PHP] what to use instead of foreach

2009-04-13 Thread PJ
t: 13 April 2009 06:48 PM > To: 'PJ' > Cc: php-general@lists.php.net > Subject: RE: [PHP] what to use instead of foreach > > Hi PJ, > > Ok, If I understand correctly you can attempt to alter your code as per > following example (I am breaking it down a little for re

RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
.com] Sent: 13 April 2009 06:48 PM To: 'PJ' Cc: php-general@lists.php.net Subject: RE: [PHP] what to use instead of foreach Hi PJ, Ok, If I understand correctly you can attempt to alter your code as per following example (I am breaking it down a little for readability): a) If you only w

RE: [PHP] what to use instead of foreach

2009-04-13 Thread Leon du Plessis
ot;title1"] . ""; Hope it is enough info for to work on for now!! Have fun! Leon -Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: 13 April 2009 04:33 PM To: Leon du Plessis Cc: php-general@lists.php.net Subject: Re: [PHP] what to use instead of foreach Hi

Re: [PHP] what to use instead of foreach

2009-04-13 Thread PJ
over the iteration through the array, > and you can play around with when & how to display what. > > Regards. > > -Original Message- > From: PJ [mailto:af.gour...@videotron.ca] > Sent: 12 April 2009 08:57 PM > To: php-general@lists.php.net > Subject: [PHP] what

Re: [PHP] what to use instead of foreach

2009-04-13 Thread PJ
Mark Kelly wrote: > Hi. > > On Sunday 12 April 2009, PJ wrote: > >> foreach does not allow for different formatting for output... >> > > [snip] > > >> But how do you get result1, result2 & result3 // with at end ? >> > > $lastIndex = count($a) - 1; // Adjust for zero-indexing. > $o

Re: [PHP] what to use instead of foreach

2009-04-13 Thread Mark Kelly
Hi. On Sunday 12 April 2009, PJ wrote: > foreach does not allow for different formatting for output... [snip] > But how do you get result1, result2 & result3 // with at end ? $lastIndex = count($a) - 1; // Adjust for zero-indexing. $outputString = ''; foreach ($a as $index => $value) { if

RE: [PHP] what to use instead of foreach

2009-04-12 Thread Leon du Plessis
a */ echo " ~~ $a ~~ "; } This way you have some added control over the iteration through the array, and you can play around with when & how to display what. Regards. -Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: 12 April 2009 08:57 PM To: php-g

Re: [PHP] what to use instead of foreach

2009-04-12 Thread Ashley Sheridan
On Sun, 2009-04-12 at 13:56 -0500, PJ wrote: > foreach does not allow for different formatting for output... > What could be used as a workaround? > example: > echo $some_result, ""; // will print all results in 1 column > echo $some_result, ","; // will print all results comma-separated in 1 row >

[PHP] what to use instead of foreach

2009-04-12 Thread PJ
foreach does not allow for different formatting for output... What could be used as a workaround? example: echo $some_result, ""; // will print all results in 1 column echo $some_result, ","; // will print all results comma-separated in 1 row But how do you get result1, result2 & result3 // with