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
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
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:
.
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
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
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
same effort in constructing the data for the
> arrays,
> so it is up to you to decide which approach is going to be best: e.g.
> $my_titles = array("title1","title2");
> $my_authors["title1"] = array("a someone, a notherone & Mr. X");
>
> The
.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
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
Hi Leon,
Thanks for the suggestion; I'm quite new to all this, so it's a bit
complicated for my peanut brain.
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
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
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
You may try something basic like:
$b = 1;
foreach ($my_array as $a)
{
echo " $a ";
//Send new line to browser
if ($b++ == 3) { echo ""; $b = 1; }
}
Or there are some different ways to approach this also like:
for ($a =& current($my_array); $a; $a = next($my_array))
{
//Format
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
>
Hey,
If anyones intrested, solved the problem like this:
function cun($num)
{
$num = number_format($num,2,'.',',');
return $num;
}
echo cun($var1);
Cheers,
-Ryan
We will slaughter you all! - The Iraqi (Dis)information ministers
*slaps self* Yep, forgot about that part of number format :)
Rob.
On Thu, 2003-09-25 at 16:51, CPT John W. Holmes wrote:
> From: "Robert Cummings" <[EMAIL PROTECTED]>
>
> > On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> > > Correct me if I'm wrong please, but I think number_format() has the
On Thu, Sep 25, 2003 at 10:01:48PM +0200, Ryan A wrote:
:
: I am running a query on the database to get the avg of a few fields, I am
: getting a result something like this:
:
: 5.
: 4.
: 5.
:
: I dont want to use such big averages and want to cut the last to digits off
: so it will
From: "Jeff McKeon" <[EMAIL PROTECTED]>
> Correct me if I'm wrong please, but I think number_format() has the
> adverse effect of changing the value type from numeric to char and
> therefore baring you from using it in mathematical equation later in the
> script.
You're correct (kind of). The _re
From: "Robert Cummings" <[EMAIL PROTECTED]>
> On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> > Correct me if I'm wrong please, but I think number_format() has the
> > adverse effect of changing the value type from numeric to char and
> > therefore baring you from using it in mathematical equati
On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote:
> Correct me if I'm wrong please, but I think number_format() has the
> adverse effect of changing the value type from numeric to char and
> therefore baring you from using it in mathematical equation later in the
> script.
>
> Anyway that's what it
om
a MySQL query...
Jeff
> -Original Message-
> From: Tyler Lane [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 25, 2003 4:20 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] What to use?
>
>
> round()
> and number_format() are what i would suggest us
round()
and number_format() are what i would suggest using.
On Thu, 2003-09-25 at 13:01, Ryan A wrote:
> Hi,
> I am running a query on the database to get the avg of a few fields, I am
> getting a result something like this:
>
> 5.
> 4.
> 5.
>
> I dont want to use such big averages a
[snip]
I dont want to use such big averages and want to cut the last to digits
off
so it will be something like:
5.00
4.00
44.23
[/snip]
http://www.php.net/number_format
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
23 matches
Mail list logo