Re: [PHP] Formatting -- defining sections of code

2012-12-15 Thread tamouse mailing lists
On Dec 14, 2012 9:49 AM, "Andy McKenzie"  wrote:
>
> Hey folks, kind of a strange question here.
>
> Basically, I've been trying to move my style from "self taught" to "Oh
> yeah, there IS a standard for this."  One of the things I frequently
> want to do is define sections of my code:  to take a simplistic
> example, "this outputs everything that needs to be in file A, this
> outputs what needs to be in file B," and so on.
>
> Up until now, I've used my own standards (generally "
> SectionName", since it's easy to search for).  But it occurs to me to
> wonder;  IS there a standard for this?  Most likely, the programming
> world being what it is, there either isn't one or there are lots of
> competing standards, but I'd be interested to know...
>
> Thanks,
>   Andy
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Actually, yes. Write smaller functions that do only one thing. DRY.
Refactor. Etc. Php include is cheap. Use the file system and names to
organize things. And if you aren't using a decent IDE or CMS,  start now.


Re: [PHP] Formatting -- defining sections of code

2012-12-14 Thread Larry Martell
On Fri, Dec 14, 2012 at 11:20 AM, Paul M Foster  wrote:
> On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote:
>
>> Hey folks, kind of a strange question here.
>>
>> Basically, I've been trying to move my style from "self taught" to "Oh
>> yeah, there IS a standard for this."  One of the things I frequently
>> want to do is define sections of my code:  to take a simplistic
>> example, "this outputs everything that needs to be in file A, this
>> outputs what needs to be in file B," and so on.
>>
>> Up until now, I've used my own standards (generally "
>> SectionName", since it's easy to search for).  But it occurs to me to
>> wonder;  IS there a standard for this?  Most likely, the programming
>> world being what it is, there either isn't one or there are lots of
>> competing standards, but I'd be interested to know...
>
> A *standard* for something? ROTFL! Yeah, like there's a standard for
> herding cats! [guffaw]

The nice thing about standards is that there are so many of them to choose from.
  -Andrew S. Tanenbaum

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting -- defining sections of code

2012-12-14 Thread Paul M Foster
On Fri, Dec 14, 2012 at 10:48:05AM -0500, Andy McKenzie wrote:

> Hey folks, kind of a strange question here.
> 
> Basically, I've been trying to move my style from "self taught" to "Oh
> yeah, there IS a standard for this."  One of the things I frequently
> want to do is define sections of my code:  to take a simplistic
> example, "this outputs everything that needs to be in file A, this
> outputs what needs to be in file B," and so on.
> 
> Up until now, I've used my own standards (generally "
> SectionName", since it's easy to search for).  But it occurs to me to
> wonder;  IS there a standard for this?  Most likely, the programming
> world being what it is, there either isn't one or there are lots of
> competing standards, but I'd be interested to know...

A *standard* for something? ROTFL! Yeah, like there's a standard for
herding cats! [guffaw]

Seriously, no I know of no such standards. It sounds like you're
thinking of the kind of thing that's more common in languages like COBOL
than anything modern. Plus, it's near impossible on any significantly
sized project to segregate code in such a way.

That said, I would recommend PHPDoc or similar. It's a package for
generating code documentation from the comments embedded in your code.
You adhere to certain conventions in the format of your comments, and
PHPDoc can scan your code and produce pretty docs. Plus, the comments
themself serve as a sort of discipline in explaining what functions and
sections of code do. If you keep your functions to singular, small tasks
(as you should), the comments are invaluable when you come back later to
try to figure out what you were thinking when you wrote this or that
block of code.

I don't know how extensive your experience is with coding or PHP. So in
case you're a relative newbie, I'd also suggest that you keep classes in
their own files (one file per class) in a "libraries" directory or
somesuch. In fact, I'd suggest downloading something like CodeIgniter,
and studying the way they structure their code physically. They may not
be the optimum example, but for a well-known framework, their code base
is relatively slim and well-organized. Also, obviously, study the MVC
(model-view-controller) paradigm. It's a very useful way of dividing up
your code's functionality.

Paul

-- 
Paul M. Foster
http://noferblatz.com
http://quillandmouse.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting

2011-01-25 Thread Jim Lucas

On 1/25/2011 9:05 PM, Ethan Rosenberg wrote:

Dear list -

I have a program with the following statement: $out = system('ls -l',
$retval); The output is a string. How do I format the output to be in
the Linux format, that is in columns. I cannot think of a way to use
explode to do it.

Advice and comments, please.

Thanks

Ethan

MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]




Well, depends, are you running this in a browser or at the console?

If you are displaying this in a browser, you are probably seeing that 
browsers do not like \n (newlines)


If in a browser, you could:
1) Wrap your output in a  HTML tag
2) Use PHP's nl2br() to replace all newlines with "" tags
3) Use PHP's header() function to tell the browser to display the output 
as plaintext.  i.e. header('Content-Type: text/plain'); [1,2]


1 - Google "php header plain text"
2 - http://www.php.net/manual/en/function.header.php#92620

If in cli...  well, you wouldn't be having this problem... :)

Jim Lucas

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting

2011-01-25 Thread joris ros
Hi You can try something like this:



> Ethan Rosenberg wrote:
>
>> Dear list -
>>
>> I have a program with the following statement: $out = system('ls -l',
>> $retval); The output is a string. How do I format the output to be in
>> the Linux format, that is in columns. I cannot think of a way to use
>> explode to do it.
>>
>> Advice and comments, please.
>>
>> Thanks
>>
>> Ethan
>>
>> MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]
>>
>
>
> Something like?:
>
> print "";
>
> $out = system('ls -l', $retval);
> print "";
>
>
> Donovan
>
>
> --
> D Brooke
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Formatting

2011-01-25 Thread Donovan Brooke

Ethan Rosenberg wrote:

Dear list -

I have a program with the following statement: $out = system('ls -l',
$retval); The output is a string. How do I format the output to be in
the Linux format, that is in columns. I cannot think of a way to use
explode to do it.

Advice and comments, please.

Thanks

Ethan

MySQL 5.1 PHP 5.3.3-6 Linux [Debian (sid)]



Something like?:

print "";
$out = system('ls -l', $retval);
print "";


Donovan


--
D Brooke

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting an ECHO statement.

2010-10-19 Thread Bob McConnell
From: Cris S

> Someone needs to hire me now, to keep me busy and stop me
> from taking this issue apart one piece at a time. Kee-rist.

That's not likely to happen soon. You have demonstrated here that you
are immature and have very little self-control or self-respect. There is
no way you would be hired for any shop that I have ever worked in.

Bob McConnell

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-19 Thread tedd

At 12:39 AM -0400 10/19/10, Paul M Foster wrote:

On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:

-snip- (of no importance)

Please go back to lurking. We'd all appreciate it, and you'll be
happier.

Paul

--
Paul M. Foster


I agree with Paul on this one.

Chris S has no idea of what we are talking about or what he is saying.

PHP does not encompass all of web programming and part of learning 
PHP programming is to know where the boundaries are.


Intermixing style elements and PHP is the topic of this thread. 
Determining what is the best practice in this aspect is what we are 
addressing.


Cheers,

tedd

--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread a...@ashleysheridan.co.uk
Steady on now, this thread started as a php question, and has only deviated a 
little. Most people on the list don't work purely with php, and I for one dont 
mind the odd off-topic thread, especially when the majority of the list is made 
of good php threads.

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: "Cris S" 
Date: Tue, Oct 19, 2010 03:46
Subject: [PHP] Formatting an ECHO statement.
To: 

At 15:12 18 10 10, Shreyas Agasthya wrote:
>Thanks all for their input. Some of the learnings  from the thread :
>
>1.  tag is getting deprecated.

Not in HTML5.

>2. Use  and 

Both? Read that shit again, buckwheat. And by "that shit" I
do mean the standards, not what Joe Bloe told you.

>3. Have CSS used to do the kind of stuff I was trying.

Uhm, yeah. @@

>  I must inform, this was already in place.

Then why the fuck are we discussing this?

>4. Keep an eye on the SE monster.

and on the "go fuck yourself" monster too.

Holy fuck, I've been lurking for months. I turn away for
one day and this is the non-PHP crap that happens?

Someone needs to hire me now, to keep me busy and stop me
from taking this issue apart one piece at a time. Kee-rist.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Shreyas Agasthya
Thanks for that detailed mail, Admin. The  was an example and I wanted to
understand how does one go about the whole formatting. Nonetheless, I am
pretty well informed after this thread.

Thanks once again, everyone.

Regards,
Shreyas

On Tue, Oct 19, 2010 at 10:09 AM, Paul M Foster wrote:

> On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:
>
> > At 15:12 18 10 10, Shreyas Agasthya wrote:
> > >Thanks all for their input. Some of the learnings  from the thread :
> > >
> > >1.  tag is getting deprecated.
> >
> > Not in HTML5.
> >
> > >2. Use  and 
> >
> > Both? Read that shit again, buckwheat. And by "that shit" I
> > do mean the standards, not what Joe Bloe told you.
> >
> > >3. Have CSS used to do the kind of stuff I was trying.
> >
> > Uhm, yeah. @@
> >
> > > I must inform, this was already in place.
> >
> > Then why the fuck are we discussing this?
> >
> > >4. Keep an eye on the SE monster.
> >
> > and on the "go fuck yourself" monster too.
> >
> > Holy fuck, I've been lurking for months. I turn away for
> > one day and this is the non-PHP crap that happens?
>
> Please go back to lurking. We'd all appreciate it, and you'll be
> happier.
>
> Paul
>
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya


Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Paul M Foster
On Mon, Oct 18, 2010 at 10:46:41PM -0400, Cris S wrote:

> At 15:12 18 10 10, Shreyas Agasthya wrote:
> >Thanks all for their input. Some of the learnings  from the thread :
> >
> >1.  tag is getting deprecated.
> 
> Not in HTML5.
> 
> >2. Use  and 
> 
> Both? Read that shit again, buckwheat. And by "that shit" I
> do mean the standards, not what Joe Bloe told you.
> 
> >3. Have CSS used to do the kind of stuff I was trying.
> 
> Uhm, yeah. @@
> 
> > I must inform, this was already in place.
> 
> Then why the fuck are we discussing this?
> 
> >4. Keep an eye on the SE monster.
> 
> and on the "go fuck yourself" monster too.
> 
> Holy fuck, I've been lurking for months. I turn away for
> one day and this is the non-PHP crap that happens?

Please go back to lurking. We'd all appreciate it, and you'll be
happier.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Cris S

At 15:12 18 10 10, Shreyas Agasthya wrote:

Thanks all for their input. Some of the learnings  from the thread :

1.  tag is getting deprecated.


Not in HTML5.


2. Use  and 


Both? Read that shit again, buckwheat. And by "that shit" I
do mean the standards, not what Joe Bloe told you.


3. Have CSS used to do the kind of stuff I was trying.


Uhm, yeah. @@


 I must inform, this was already in place.


Then why the fuck are we discussing this?


4. Keep an eye on the SE monster.


and on the "go fuck yourself" monster too.

Holy fuck, I've been lurking for months. I turn away for
one day and this is the non-PHP crap that happens?

Someone needs to hire me now, to keep me busy and stop me
from taking this issue apart one piece at a time. Kee-rist.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Cris S

At 13:03 18 10 10, a...@ashleysheridan.co.uk wrote:
There's nothing wrong with using  as it indicates emphasised 
text, which is semantic. Use span tags with classes only when the 
content you're styling has no semantic alternative. 
important message is much better for machines 
(including search engines, screen readers, etc) to infer a meaning 
for than important message Thanks, 
Ash http://www.ashleysheridan.co.uk - Reply message - From: 
"tedd"  Date: Mon, Oct 18, 2010 17:51 
Subject: [PHP] Formatting an ECHO statement. To: 
 At 9:47 AM -0400 10/18/10, Steve Staples 
wrote: >or create a style sheet, with a class definition for 
italic. > >Steve. +1 The "best practices" way to do it. Don't style 
output in an echo statement, but rather put styling in a css sheet, 
It's much cleaner there. Cheers, tedd -- --- 
http://sperling.com/ -- PHP General Mailing List 
(http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Jesus H. Christ.

I'm on this list because I want to learn PHP, not how to parse
HTML mail or how to add italics to dolt/dolt.

You add styles to text as a presentation effect. This list is
not supposed to be about the effing presentation.

Must I say it again, more rudely even? I know you guys like
to go on and on, but give it a rest on this one. Get your
asses back on topic - and on topical jokes. This topic is
neither.

Move on already.




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting an ECHO statement.

2010-10-18 Thread admin
I ask as you look at the comments and replies to your post, you think long
term. 
Today you want the italic option, tomorrow you want to change the display to
something else.  Now you have to go back and change ever place you set the
italic symbols to make your change. 

BUT if you use styles you can not only change the display to the desired
look in one location but you can have flexibility.

Example:

Let's say the comments are coming from a database and you want to display
the comment differently based on the contents of the comment.

In my example I have 3 different classes in the style. Now as I foreach over
the fake data array example, I simply pick the style to use based on each
matching criteria. While the static examples


#wever_comment{font-style:italic}
#good_comment{font-style:italic; color: green;}
#bad_comment{font-weight:bold; color: red;}


$variable_from_database = array('good','bad','whatever');
Foreach($variable as $key)
{
Echo 'Other Comments:';
If(preg_match("/bad/i",'$key')){Echo '$key';}
If(preg_match("/good/i",'$key')){Echo '$key';}
If(preg_match("/whatever/i",'$key')){Echo '$key';}
Echo '';
}

In the long term the flexibility allows you to make faster changes with a
higher degree, of what I like to call "smarter code". Yes the filters are
static, and I would not use static filters personally. It is meant as an
explanation, not a how to.











-Original Message-
From: Shreyas Agasthya [mailto:shreya...@gmail.com] 
Sent: Monday, October 18, 2010 6:10 AM
To: PHP General List
Subject: [PHP] Formatting an ECHO statement.

Team,

A bit of silly one but like my book says, there are no dumb questions, I am
asking it here.

If I have :

$other="Whatever";

and I do:

echo 'Other Comments:' .$other. '

works perfectly well and prints the value. What if I want to, now, italicize
the value of $other with the above syntax? How do I achieve it?

I know we can do it this way : echo " I am $other"; but I want to
learn how to do it with the above syntax like I mentioned earlier.

Regards,
Shreyas Agasthya


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Shreyas Agasthya
Thanks all for their input. Some of the learnings  from the thread :

1.  tag is getting deprecated.
2. Use  and 
3. Have CSS used to do the kind of stuff I was trying. I must inform, this
was already in place.
4. Keep an eye on the SE monster.

Regards,
Shreyas

On Mon, Oct 18, 2010 at 11:43 PM, Andrew Ballard  wrote:

> On Mon, Oct 18, 2010 at 1:28 PM, tedd  wrote:
> > At 6:03 PM +0100 10/18/10, a...@ashleysheridan.co.uk wrote:
> >>
> >> There's nothing wrong with using  as it indicates emphasised text,
> >> which is semantic. Use span tags with classes only when the content
> you're
> >> styling has no semantic alternative.
> >>
> >> important message is much better for machines
> (including
> >> search engines, screen readers, etc) to infer a meaning for than
> >> important message
> >>
> >> Thanks,
> >> Ash
> >> http://www.ashleysheridan.co.uk
> >
> > While using the em tag as you describe will certainly work, but what
> happens
> > when the designer wants to change the style of an em tag to something
> else
> > and doesn't want the output from your code to change?
> >
> > I have found it better to leave styling to the designer.
> >
>
> That is the exactly the intended purpose of the  and
>  tags: they simply indicate semantically that the
> enclosed text is either emphasized or strong (or, if nested, the text
> would be strongly emphasized? ;-) ), and it is up to CSS to define
> what that should look like. The appearance can easily change at any
> time without changing the HTML itself, just as you suggest.
>
> While the same is technically true of italic and bold,
> those tags by definition imply a specific way to render the content
> that they contain, which makes a real confusion in cases such as  style="font-style: normal; font-weight: bold;">text.
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Regards,
Shreyas Agasthya


Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Andrew Ballard
On Mon, Oct 18, 2010 at 1:28 PM, tedd  wrote:
> At 6:03 PM +0100 10/18/10, a...@ashleysheridan.co.uk wrote:
>>
>> There's nothing wrong with using  as it indicates emphasised text,
>> which is semantic. Use span tags with classes only when the content you're
>> styling has no semantic alternative.
>>
>> important message is much better for machines (including
>> search engines, screen readers, etc) to infer a meaning for than
>> important message
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>
> While using the em tag as you describe will certainly work, but what happens
> when the designer wants to change the style of an em tag to something else
> and doesn't want the output from your code to change?
>
> I have found it better to leave styling to the designer.
>

That is the exactly the intended purpose of the  and
 tags: they simply indicate semantically that the
enclosed text is either emphasized or strong (or, if nested, the text
would be strongly emphasized? ;-) ), and it is up to CSS to define
what that should look like. The appearance can easily change at any
time without changing the HTML itself, just as you suggest.

While the same is technically true of italic and bold,
those tags by definition imply a specific way to render the content
that they contain, which makes a real confusion in cases such as text.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread tedd

At 6:03 PM +0100 10/18/10, a...@ashleysheridan.co.uk wrote:
There's nothing wrong with using  as it indicates emphasised 
text, which is semantic. Use span tags with classes only when the 
content you're styling has no semantic alternative.


important message is much better for machines 
(including search engines, screen readers, etc) to infer a meaning 
for than

important message

Thanks,
Ash
http://www.ashleysheridan.co.uk


While using the em tag as you describe will certainly work, but what 
happens when the designer wants to change the style of an em tag to 
something else and doesn't want the output from your code to change?


I have found it better to leave styling to the designer.

One can compromise by using a class such as "class=warning" or 
"class=output" and then addressing the style of the output in a style 
sheet. Such as:


echo("span class='warning'>$output");

Now, you do have a point regarding SE, where some SE's look to the em 
and strong tags to determine word weight in ranking, but therein also 
lies a problem. What if the client doesn't want the output from code 
to be considered in SE's? After all, if output is static, then why 
code it? If it is variable, then that will cause your ranking to 
change. Sounds like disaster to me.


My choice to is to leave the styling, SE, screen readers, and other 
such concerns to those who know more than I do. Just give me a style 
class and let me work on the code.


Cheers,

tedd

--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread tedd

At 9:47 AM -0400 10/18/10, Steve Staples wrote:

or create a style sheet, with a class definition for italic.

Steve.



+1

The "best practices" way to do it.

Don't style output in an echo statement, but rather put styling in a 
css sheet, It's much cleaner there.


Cheers,

tedd

--
---
http://sperling.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Steve Staples
On Mon, 2010-10-18 at 09:25 -0400, Paul M Foster wrote:
> On Mon, Oct 18, 2010 at 03:40:03PM +0530, Shreyas Agasthya wrote:
> 
> > Team,
> > 
> > A bit of silly one but like my book says, there are no dumb questions, I am
> > asking it here.
> > 
> > If I have :
> > 
> > $other="Whatever";
> > 
> > and I do:
> > 
> > echo 'Other Comments:' .$other. '
> > 
> > works perfectly well and prints the value. What if I want to, now, italicize
> > the value of $other with the above syntax? How do I achieve it?
> > 
> > I know we can do it this way : echo " I am $other"; but I want to
> > learn how to do it with the above syntax like I mentioned earlier.
> 
> No, there's no other way to do it. You're outputting to HTML, and if you
> want to have the HTML output italicized, you must surround the term with
> the proper code. And in this case, the proper code is actually '',
> not ''. The '' code is being deprecated.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 

Another option: 

echo 'Other Comments: '.
$other .'';

or create a style sheet, with a class definition for italic.

Steve.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Paul M Foster
On Mon, Oct 18, 2010 at 03:40:03PM +0530, Shreyas Agasthya wrote:

> Team,
> 
> A bit of silly one but like my book says, there are no dumb questions, I am
> asking it here.
> 
> If I have :
> 
> $other="Whatever";
> 
> and I do:
> 
> echo 'Other Comments:' .$other. '
> 
> works perfectly well and prints the value. What if I want to, now, italicize
> the value of $other with the above syntax? How do I achieve it?
> 
> I know we can do it this way : echo " I am $other"; but I want to
> learn how to do it with the above syntax like I mentioned earlier.

No, there's no other way to do it. You're outputting to HTML, and if you
want to have the HTML output italicized, you must surround the term with
the proper code. And in this case, the proper code is actually '',
not ''. The '' code is being deprecated.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Tommy Pham
> -Original Message-
> From: Shreyas Agasthya [mailto:shreya...@gmail.com]
> Sent: Monday, October 18, 2010 3:10 AM
> To: PHP General List
> Subject: [PHP] Formatting an ECHO statement.
> 
> Team,
> 
> A bit of silly one but like my book says, there are no dumb questions, I
am
> asking it here.
> 
> If I have :
> 
> $other="Whatever";
> 
> and I do:
> 
> echo 'Other Comments:' .$other. '


echo 'Other Comments:' .$other. '';

> 
> works perfectly well and prints the value. What if I want to, now,
italicize
> the value of $other with the above syntax? How do I achieve it?
> 
> I know we can do it this way : echo " I am $other"; but I want to
learn
> how to do it with the above syntax like I mentioned earlier.
> 
> Regards,
> Shreyas Agasthya


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting an ECHO statement.

2010-10-18 Thread Ford, Mike
> -Original Message-
> From: Shreyas Agasthya [mailto:shreya...@gmail.com]
> Sent: 18 October 2010 11:10
> 
> A bit of silly one but like my book says, there are no dumb
> questions, I am
> asking it here.
> 
> If I have :
> 
> $other="Whatever";
> 
> and I do:
> 
> echo 'Other Comments:' .$other. '
> 
> works perfectly well and prints the value. What if I want to, now,
> italicize
> the value of $other with the above syntax? How do I achieve it?

   echo 'Other Comments:' .$other. '

Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Rick Dwyer

Thank you Nathan,
This worked quite well.
 --Rick

On Jan 22, 2010, at 8:10 PM, Nathan Rixham wrote:


Rick Dwyer wrote:

On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:
Thanks Nathan I'll give it a shot.



np - here's a more condensed version:

function round_to_half_cent( $value )
{
$value = ($value*100) + 0.3;
$out = number_format( floor($value)/100 , 2 );
return $out . ($value > .5+(int)$value ? '5' : '');
}



echo round_to_half_cent( 12.1 );   // 12.10
echo round_to_half_cent( 12.103 ); // 12.105
echo round_to_half_cent( 12.107 ); // 12.11
echo round_to_half_cent( 123456.789 ); // 123,456.79



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php








--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Nathan Rixham
Rick Dwyer wrote:
> On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:
> Thanks Nathan I'll give it a shot.
> 

np - here's a more condensed version:

function round_to_half_cent( $value )
{
$value = ($value*100) + 0.3;
$out = number_format( floor($value)/100 , 2 );
return $out . ($value > .5+(int)$value ? '5' : '');
}

>>
>> echo round_to_half_cent( 12.1 );   // 12.10
>> echo round_to_half_cent( 12.103 ); // 12.105
>> echo round_to_half_cent( 12.107 ); // 12.11
>> echo round_to_half_cent( 123456.789 ); // 123,456.79
>>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Rick Dwyer


On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:


Thanks Nathan I'll give it a shot.

 --Rick






your doing the number format before the rounding.. here's a version of
the function that should fit the bill:

function round_to_half_cent( $value )
{
$value *= 100;
if( $value == (int)$value || $value < ((int)$value)+0.3 ) {
return number_format( (int)$value/100 , 2);
} else if($value > ((int)$value)+0.6) {
return number_format( (int)++$value/100 , 2);
}
return number_format( 0.005+(int)$value/100 , 3);
}


echo round_to_half_cent( 12.1 );   // 12.10
echo round_to_half_cent( 12.103 ); // 12.105
echo round_to_half_cent( 12.107 ); // 12.11
echo round_to_half_cent( 123456.789 ); // 123,456.79









--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Nathan Rixham
Rick Dwyer wrote:
> 
> On Jan 22, 2010, at 4:24 PM, tedd wrote:
> 
>>> Hello List.
>>>
>>> In an earlier post, I received help with a custom function to round
>>> decimals off (the custom function provided by Adam Richardson is below).
>>>
>>> However in my MySQL db, when I have values with only 1 decimal point,
>>> I need the value PHP returns to display as 2.  For example, 3.8 needs
>>> to display as 3.80.
>>>
>>> My line of code that calls the custom function looks like this:
>>>
>>> $my_price = round_to_half_cent(number_format($my_price, 3, '.', ','));
>>>

your doing the number format before the rounding.. here's a version of
the function that should fit the bill:

function round_to_half_cent( $value )
{
$value *= 100;
if( $value == (int)$value || $value < ((int)$value)+0.3 ) {
return number_format( (int)$value/100 , 2);
} else if($value > ((int)$value)+0.6) {
return number_format( (int)++$value/100 , 2);
}
return number_format( 0.005+(int)$value/100 , 3);
}


echo round_to_half_cent( 12.1 );   // 12.10
echo round_to_half_cent( 12.103 ); // 12.105
echo round_to_half_cent( 12.107 ); // 12.11
echo round_to_half_cent( 123456.789 ); // 123,456.79



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-22 Thread Nathan Rixham
Paul M Foster wrote:
> On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:
> 
>> --Rick:
>>
>> The above described rounding algorithm introduces more bias than
>> simply using PHP's round() function, which always rounds down. IMO,
>> modifying rounding is not worth the effort.
>>
>> The "best" rounding algorithm is to look at the last digit and do this:
>>
>> 0 -- no rounding needed.
>> 1-4 round down.
>> 6-9 round up.
>>
>> In the case of 5, then look to the number that precedes it -- if it
>> is even, then round up and if it is odd, then round down -- or vise
>> versa, it doesn't make any difference as long as you are consistent.
>>
>> Here are some examples:
>>
>> 122.4  <-- round down (122)
>> 122.6 <-- round up (123)
>> 122.5 <-- round up (123)
>>
>> 123.4  <-- round down (123)
>> 123.6 <-- round up (124)
>> 123.5 <-- round down (123)
>>
>> There are people who claim that there's no difference, or are at odds
>> with this method, but they simply have not investigated the problem
>> sufficiently to see the bias that rounding up/down causes. However,
>> that difference is very insignificant and can only be seen after tens
>> of thousands iterations.  PHP's rounding function is quite sufficient.
> 
> This is called (among other things) "banker's rounding". But PHP's
> round() function won't do banker's rounding, as far as I know.
> 
> Paul
> 

floor( $val + 0.5 );

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Rick Dwyer


On Jan 22, 2010, at 4:24 PM, tedd wrote:


Hello List.

In an earlier post, I received help with a custom function to round  
decimals off (the custom function provided by Adam Richardson is  
below).


However in my MySQL db, when I have values with only 1 decimal  
point, I need the value PHP returns to display as 2.  For example,  
3.8 needs to display as 3.80.


My line of code that calls the custom function looks like this:

$my_price = round_to_half_cent(number_format($my_price, 3, '.',  
','));


When the value of $my_price is 3.81, it returns 3.81.  However,  
when the value of $my_price is 3.8 that is what it returns.


How can I force the formatting of my_price to always contain either  
2 or 3 decimal points (3 if the original number contains 3 or more  
decimal points to begin with)



Thanks,

--Rick



Rick:

Okay so 3.8 is stored in the database and not as 3.80 -- but that's  
not a problem. What you have is a display problem so use one of the  
many PHP functions to display numbers and don't worry about how it's  
stored.



Hi Ted.

This is exactly what I am trying to do, some of the values in the DB  
are going to have 3 decimals, some 2 and some 1.


On my page I pull the value from the db with:

$my_price = $row['my_price'];

This returns 3.80... even though my db has it as 3.8.  No problem.   
But once I run the variable $my_price through the following line of  
code, it is truncating the 0:


$my_price = round_to_half_cent(number_format($my_price, 3, '.', ','));

Again, the above call to the custom function works fine for 2 and 3  
decimal points just not 1 decimal point.  Because I call this  
function over many pages, I would prefer if possible to fix it at the  
custom function level rather than recode each page.  But I will do  
whatever is necessary.  I afraid with my current understanding of PHP  
I am not able to successfully modify the custom function to tack on a  
0 when the decimal place is empty.  Will keep trying and post if I am  
successful


Thanks,

--Rick




I'm afraid with my current understanding of PHP, I am not able to come  
up with the logic to


 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread tedd

Hello List.

In an earlier post, I received help with a custom function to round 
decimals off (the custom function provided by Adam Richardson is 
below).


However in my MySQL db, when I have values with only 1 decimal 
point, I need the value PHP returns to display as 2.  For example, 
3.8 needs to display as 3.80.


My line of code that calls the custom function looks like this:

$my_price = round_to_half_cent(number_format($my_price, 3, '.', ','));

When the value of $my_price is 3.81, it returns 3.81.  However, when 
the value of $my_price is 3.8 that is what it returns.


How can I force the formatting of my_price to always contain either 
2 or 3 decimal points (3 if the original number contains 3 or more 
decimal points to begin with)



Thanks,

--Rick



Rick:

Okay so 3.8 is stored in the database and not as 3.80 -- but that's 
not a problem. What you have is a display problem so use one of the 
many PHP functions to display numbers and don't worry about how it's 
stored.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals Further Help

2010-01-22 Thread Rick Dwyer

Hello List.

In an earlier post, I received help with a custom function to round  
decimals off (the custom function provided by Adam Richardson is below).


However in my MySQL db, when I have values with only 1 decimal point,  
I need the value PHP returns to display as 2.  For example, 3.8 needs  
to display as 3.80.


My line of code that calls the custom function looks like this:

$my_price = round_to_half_cent(number_format($my_price, 3, '.', ','));

When the value of $my_price is 3.81, it returns 3.81.  However, when  
the value of $my_price is 3.8 that is what it returns.


How can I force the formatting of my_price to always contain either 2  
or 3 decimal points (3 if the original number contains 3 or more  
decimal points to begin with)



Thanks,

--Rick



On Jan 11, 2010, at 10:39 PM, Adam Richardson wrote:

On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund >wrote:



tedd wrote:


At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half  
cent.


So if the 3rd decimal spot ends in 1 or 2, it gets rounded down  
to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or  
9 it

gets rounded up to full cents.

Can this be done fairly easily?  Not knowing PHP well, I am not  
aware of

the logic to configure this accordingly.

Thanks,
--Rick




--Rick:

The above described rounding algorithm introduces more bias than  
simply
using PHP's round() function, which always rounds down. IMO,  
modifying

rounding is not worth the effort.

The "best" rounding algorithm is to look at the last digit and do  
this:


0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if  
it is
even, then round up and if it is odd, then round down -- or vise  
versa, it

doesn't make any difference as long as you are consistent.

Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at  
odds with
this method, but they simply have not investigated the problem  
sufficiently
to see the bias that rounding up/down causes. However, that  
difference is
very insignificant and can only be seen after tens of thousands  
iterations.

PHP's rounding function is quite sufficient.

Cheers,

tedd


However that's not what Rick is asking for. He needs a function  
that rounds

to the half penny with a bias to rounding up (greedy bosses):


Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020+.003
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias   +.005

This could easily be implemented by getting the 3rd decimal and  
using it in

a switch() statement.

An unbiased system could look like:

Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020-.002
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias.000

The only difference is the case where the third decimal is 7.

Cheers,

Mattias


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Here you go, Rick.  Just send the check in the mail ;)

function round_to_half_cent($amount)
{
if (!is_numeric($amount)) throw new Exception('The amount received  
by the

"round_to_half_cent" function was not numeric');
$parts = explode('.', str_replace(',', '', (string)$amount));
if (count($parts) >= 3) throw new Exception('The amount received by  
the

"round_to_half_cent" function had too many decimals.');
if (count($parts) == 1)
{
return $amount;
}
$digit = substr($parts[1], 2, 1);
if ($digit == 0 || $digit == 1 || $digit == 2)
{
$digit = 0;
}
elseif ($digit == 3 || $digit == 4 || $digit == 5 || $digit == 6)
{
$digit = .005;
}
elseif ($digit == 7 || $digit == 8 || $digit == 9)
{
$digit = .01;
}
else
{
throw new Exception('OK, perhaps we are talking about different  
types of

numbers :(  Check the input to the "round_to_half_cent" function.');
}
return (double)($parts[0].'.'.substr($parts[1], 0, 2)) + $digit;
}

echo "5.002 = ".round_to_half_cent(5.002);
echo "70,000.126 = ".round_to_half_cent("7.126");
echo "55.897 = ".round_to_half_cent(55.897);
// should cause exception
echo "One hundred = ".round_to_half_cent("One hundred");

--
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com



 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:

>
> --Rick:
>
> The above described rounding algorithm introduces more bias than
> simply using PHP's round() function, which always rounds down. IMO,
> modifying rounding is not worth the effort.
>
> The "best" rounding algorithm is to look at the last digit and do this:
>
> 0 -- no rounding needed.
> 1-4 round down.
> 6-9 round up.
>
> In the case of 5, then look to the number that precedes it -- if it
> is even, then round up and if it is odd, then round down -- or vise
> versa, it doesn't make any difference as long as you are consistent.
>
> Here are some examples:
>
> 122.4  <-- round down (122)
> 122.6 <-- round up (123)
> 122.5 <-- round up (123)
>
> 123.4  <-- round down (123)
> 123.6 <-- round up (124)
> 123.5 <-- round down (123)
>
> There are people who claim that there's no difference, or are at odds
> with this method, but they simply have not investigated the problem
> sufficiently to see the bias that rounding up/down causes. However,
> that difference is very insignificant and can only be seen after tens
> of thousands iterations.  PHP's rounding function is quite sufficient.

This is called (among other things) "banker's rounding". But PHP's
round() function won't do banker's rounding, as far as I know.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Adam Richardson
On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund wrote:

> tedd wrote:
>
>> At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
>>
>>> I have been asked to further modify the value to the nearest half cent.
>>>
>>> So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
>>> If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
>>> gets rounded up to full cents.
>>>
>>> Can this be done fairly easily?  Not knowing PHP well, I am not aware of
>>> the logic to configure this accordingly.
>>>
>>> Thanks,
>>> --Rick
>>>
>>
>>
>> --Rick:
>>
>> The above described rounding algorithm introduces more bias than simply
>> using PHP's round() function, which always rounds down. IMO, modifying
>> rounding is not worth the effort.
>>
>> The "best" rounding algorithm is to look at the last digit and do this:
>>
>> 0 -- no rounding needed.
>> 1-4 round down.
>> 6-9 round up.
>>
>> In the case of 5, then look to the number that precedes it -- if it is
>> even, then round up and if it is odd, then round down -- or vise versa, it
>> doesn't make any difference as long as you are consistent.
>>
>> Here are some examples:
>>
>> 122.4  <-- round down (122)
>> 122.6 <-- round up (123)
>> 122.5 <-- round up (123)
>>
>> 123.4  <-- round down (123)
>> 123.6 <-- round up (124)
>> 123.5 <-- round down (123)
>>
>> There are people who claim that there's no difference, or are at odds with
>> this method, but they simply have not investigated the problem sufficiently
>> to see the bias that rounding up/down causes. However, that difference is
>> very insignificant and can only be seen after tens of thousands iterations.
>>  PHP's rounding function is quite sufficient.
>>
>> Cheers,
>>
>> tedd
>>
>>
> However that's not what Rick is asking for. He needs a function that rounds
> to the half penny with a bias to rounding up (greedy bosses):
>
>
> Actual Rounded Diff
> .011   .010-.001
> .012   .010-.002
> .013   .015+.002
> .014   .015+.001
> .015   .015 .000
> .016   .015-.001
> .017   .020+.003
> .018   .020+.002
> .019   .020+.001
> .020   .020 .000
> Bias   +.005
>
> This could easily be implemented by getting the 3rd decimal and using it in
> a switch() statement.
>
> An unbiased system could look like:
>
> Actual Rounded Diff
> .011   .010-.001
> .012   .010-.002
> .013   .015+.002
> .014   .015+.001
> .015   .015 .000
> .016   .015-.001
> .017   .020-.002
> .018   .020+.002
> .019   .020+.001
> .020   .020 .000
> Bias.000
>
> The only difference is the case where the third decimal is 7.
>
> Cheers,
>
> Mattias
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Here you go, Rick.  Just send the check in the mail ;)

function round_to_half_cent($amount)
{
if (!is_numeric($amount)) throw new Exception('The amount received by the
"round_to_half_cent" function was not numeric');
 $parts = explode('.', str_replace(',', '', (string)$amount));
 if (count($parts) >= 3) throw new Exception('The amount received by the
"round_to_half_cent" function had too many decimals.');
 if (count($parts) == 1)
{
return $amount;
}
 $digit = substr($parts[1], 2, 1);
 if ($digit == 0 || $digit == 1 || $digit == 2)
{
$digit = 0;
}
elseif ($digit == 3 || $digit == 4 || $digit == 5 || $digit == 6)
{
$digit = .005;
}
elseif ($digit == 7 || $digit == 8 || $digit == 9)
{
$digit = .01;
}
else
{
throw new Exception('OK, perhaps we are talking about different types of
numbers :(  Check the input to the "round_to_half_cent" function.');
}
 return (double)($parts[0].'.'.substr($parts[1], 0, 2)) + $digit;
}

echo "5.002 = ".round_to_half_cent(5.002);
echo "70,000.126 = ".round_to_half_cent("7.126");
echo "55.897 = ".round_to_half_cent(55.897);
// should cause exception
echo "One hundred = ".round_to_half_cent("One hundred");

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Formatting Decimals

2010-01-11 Thread Mattias Thorslund

tedd wrote:

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware 
of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it is 
even, then round up and if it is odd, then round down -- or vise 
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at odds 
with this method, but they simply have not investigated the problem 
sufficiently to see the bias that rounding up/down causes. However, 
that difference is very insignificant and can only be seen after tens 
of thousands iterations.  PHP's rounding function is quite sufficient.


Cheers,

tedd



However that's not what Rick is asking for. He needs a function that 
rounds to the half penny with a bias to rounding up (greedy bosses):



Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020+.003
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias   +.005

This could easily be implemented by getting the 3rd decimal and using it 
in a switch() statement.


An unbiased system could look like:

Actual Rounded Diff
.011   .010-.001
.012   .010-.002
.013   .015+.002
.014   .015+.001
.015   .015 .000
.016   .015-.001
.017   .020-.002
.018   .020+.002
.019   .020+.001
.020   .020 .000
Bias.000

The only difference is the case where the third decimal is 7.

Cheers,

Mattias

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Rick Dwyer


On Jan 11, 2010, at 4:56 PM, tedd wrote:


At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half  
cent.


So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9  
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not  
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than  
simply using PHP's round() function, which always rounds down. IMO,  
modifying rounding is not worth the effort.


I understand what you are saying and I agree.  But the decision to  
round to half cents as outlined above is a client requirement, not  
mine (I did try to talk them out of it but no luck).


I come from an LDML environment, not a PHP one so I don't know the  
actual code to make this happen.  But the logic would be something like:


If 3 decimal than look at decimal in position 3.

If value = 1 or 2 set it to 0
If value = 3,4,5,6 round it to 5
If value = 7,8,9 round it to a full cent


Anybody have specific code examples to make this happen?

Thanks,

--Rick








The "best" rounding algorithm is to look at the last digit and do  
this:


0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it  
is even, then round up and if it is odd, then round down -- or vise  
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at  
odds with this method, but they simply have not investigated the  
problem sufficiently to see the bias that rounding up/down causes.  
However, that difference is very insignificant and can only be seen  
after tens of thousands iterations.  PHP's rounding function is  
quite sufficient.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread tedd

At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 
it gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not 
aware of the logic to configure this accordingly.


Thanks,
--Rick



--Rick:

The above described rounding algorithm introduces more bias than 
simply using PHP's round() function, which always rounds down. IMO, 
modifying rounding is not worth the effort.


The "best" rounding algorithm is to look at the last digit and do this:

0 -- no rounding needed.
1-4 round down.
6-9 round up.

In the case of 5, then look to the number that precedes it -- if it 
is even, then round up and if it is odd, then round down -- or vise 
versa, it doesn't make any difference as long as you are consistent.


Here are some examples:

122.4  <-- round down (122)
122.6 <-- round up (123)
122.5 <-- round up (123)

123.4  <-- round down (123)
123.6 <-- round up (124)
123.5 <-- round down (123)

There are people who claim that there's no difference, or are at odds 
with this method, but they simply have not investigated the problem 
sufficiently to see the bias that rounding up/down causes. However, 
that difference is very insignificant and can only be seen after tens 
of thousands iterations.  PHP's rounding function is quite sufficient.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Paul M Foster
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:

> I have been asked to further modify the value to the nearest half cent.
>
> So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
> If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it
> gets rounded up to full cents.
>
> Can this be done fairly easily?  Not knowing PHP well, I am not aware
> of the logic to configure this accordingly.

Yes, this can be done, but you'll need to write a function to do it
yourself. I'd also suggest you look into the BCMath functions, at:

http://us2.php.net/manual/en/book.bc.php

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Rick Dwyer

I have been asked to further modify the value to the nearest half cent.

So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5.  And if it 7, 8 or 9 it  
gets rounded up to full cents.


Can this be done fairly easily?  Not knowing PHP well, I am not aware  
of the logic to configure this accordingly.


Thanks,
--Rick




On Jan 11, 2010, at 10:55 AM, Ryan Sun wrote:


$newprice =  sprintf("$%.2f", 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer   
wrote:

Hello List.

Probably an easy question, but I am not able to format a number to  
round up from 3 numbers after the decimal to just 2.


My code looks like this:

$newprice = "$".number_format($old_price, 2, ".", ",");

and this returns "$0.109" when I am looking for "$0.11".


I tried:

$newprice = "$".round(number_format($old_price, 2, ".", ","),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Decimals

2010-01-11 Thread Ryan Sun
$newprice =  sprintf("$%.2f", 15.109);

On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer  wrote:

> Hello List.
>
> Probably an easy question, but I am not able to format a number to round up
> from 3 numbers after the decimal to just 2.
>
> My code looks like this:
>
> $newprice = "$".number_format($old_price, 2, ".", ",");
>
> and this returns "$0.109" when I am looking for "$0.11".
>
>
> I tried:
>
> $newprice = "$".round(number_format($old_price, 2, ".", ","),2);
> But no luck.
>
> Any help is appreciated.
>
> Thanks,
>
>  --Rick
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Formatting Decimals

2010-01-10 Thread Mattias Thorslund

Testing this out a little:

matt...@mumin:~$ php -r 'echo "\$".number_format(0.109, 2, ".", ",")."\n";'
$0.11
matt...@mumin:~$ php -r 'echo "$".number_format(0.109, 2, ".", ",")."\n";'
$0.11
matt...@mumin:~$ php -r 'echo "$".number_format("0.109", 2, ".", 
",")."\n";'

$0.11

I think the $ should be escaped with a backslash when enclosed within 
double quotes, but even the second and third tries return the correct 
result for me. Using PHP 5.2.10.


Cheers,

Mattias

Rick Dwyer wrote:

Hello List.

Probably an easy question, but I am not able to format a number to 
round up from 3 numbers after the decimal to just 2.


My code looks like this:

$newprice = "$".number_format($old_price, 2, ".", ",");

and this returns "$0.109" when I am looking for "$0.11".


I tried:

$newprice = "$".round(number_format($old_price, 2, ".", ","),2);
But no luck.

Any help is appreciated.

Thanks,

 --Rick






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread kranthi
\n";
}

wont this do ?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread b

On 07/30/2009 06:29 PM, Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct formatted
tables similar to HTML?




Are you thinking of a CSV file that you can open in a spreadsheet prog? 
Or, do you literally mean a plaintext file with columns? For the latter, 
you'd need to measure the max char length of each "column" for every 
line in the file, then go back and print each line using str_pad().



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread Robert Cummings

Skip Evans wrote:

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?

or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct 
formatted tables similar to HTML?


You can use a combination of wordwrap(), str_pad(), and swathe of 
judicious (but simplistic) math :)


Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread Skip Evans

Jim Lucas wrote:

Skip Evans wrote:

Hey all,

Am I brain fading or what? I'm so used to formatting text in tables for
HTML display I can't think of how to do it for a plain text file.

I just need to create a columned table of names and addresses type
stuff... sprintf?


or a little str_pad on each variable...



Sure, that will do it. But isn't there some way to construct 
formatted tables similar to HTML?



--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting plain text file

2009-07-30 Thread Jim Lucas
Skip Evans wrote:
> Hey all,
> 
> Am I brain fading or what? I'm so used to formatting text in tables for
> HTML display I can't think of how to do it for a plain text file.
> 
> I just need to create a columned table of names and addresses type
> stuff... sprintf?

or a little str_pad on each variable...



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-08 Thread PJ
Ford, Mike wrote:
> On 04 June 2009 19:09, PJ advised:
>
>   
>> Nitsan Bin-Nun wrote:
>> 
 From my experience I tend to use a difference ID for the
 
>> body tag, for
>> 
>>> instance  and then format it in my CSS using ID
>>> reference: #homepage .classname {
>>>   color: blue;
>>> }
>>>
>>> This way you can use a default format for all the pages and create
>>>   
> minor
>   
>>> (or major) changes in the theme in no time :)
>>>
>>> I would also suggest to attach the CSS filename reference at the
>>>   
> 
>   
>>> tag the update time of the file, so that the browser will
>>>   
> automatically
>   
>>> update the cache of the CSS whenever you decide to edit it.
>>>
>>> Just my 2 cents ;)
>>>
>>>   
>> Oh, I think it's worth a lot more than that.
>> I just installed IE 8 just to have it for verification. It's no better
>> than IE 6. I never use them personally.
>> But how do you produce interesting web pages to look well on both
>> without making stupid compromises. What looks well on Firefox, looks
>> 
> like
>   
>> MSshit on IE. 
>> 
>
> This may be a silly question, but reading this just makes me wonder --
> you do have an appropriate  to prevent IE going into Quirks Mode?
>   
I do, thanks. PJ
> I don't usually have *that* much trouble getting IE to render very
> similarly to Firefox (and IE8 is reportedly much better), but if IE is
> in Quirks Mode it makes a huge difference and presents all sorts of
> rendering problems. (The Firefox Web Developer plugin will tell you if a
> page is rendering in Quirks Mode or Standards Compliance Mode.)
>
> Cheers!
>
> Mike
>
>  --
> Mike Ford,  Electronic Information Developer,
> C507, Leeds Metropolitan University, Civic Quarter Campus, 
> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
> Email: m.f...@leedsmet.ac.uk
> Tel: +44 113 812 4730
>
>
> To view the terms under which this email is distributed, please go to 
> http://disclaimer.leedsmet.ac.uk/email.htm
>
>   


-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-05 Thread PJ
Peter Ford wrote:
> PJ wrote:
>   
>> tedd wrote:
>> 
>>> At 3:58 PM -0400 6/4/09, PJ wrote:
>>>   
 tedd wrote:

  > Style sheets are meant simplify things so decide on how you want
 
>  things to look uniformly throughout your site and then stick with it.
>  There's really no good reason to keep changing things throughout a
> site.
>
>  Cheers,
>
>  tedd
>
>
>   
 Maybe I'm just too complicated. ;-)
 I do try to keep it simple. But then, little things creep in, like a
 login box on the index page which mucks up all the other pages. Then
 there is a recipe page which is totally different, yet to keep is
 stylistically continuous it uses a similar layout to the other pages but
 different. The same for the main recipe page, and the same for the
 portraits of producers - all the pages are different yet remain within a
 cohesive style. CSS gets super bloated and almost unamageable. Most
 sites are very repetitive; mine tend to be "provocative" or semthing
 like that. I really don't see an ooption. Although, Nitsan's body tags
 sound promising. I'll have to try that; maybe the solution is to do a
 series of definitions unique just fo certain pages. :-)
 
>>> That's simply an example of not thinking things out before you write
>>> the code.
>>>
>>> First you figure out a layout, then you populate it. You don't pick a
>>> layout, populate it and then change the layout. That leads to a
>>> lackluster and "lack of thought" site.
>>>
>>> Cheers,
>>>
>>> tedd
>>>
>>>
>>>   
>> If only it were that simple.
>> When one is developing, one is always changing. And even when you're
>> finally "live and on the air", you will still be changing or else your
>> site will die before your client gets a chance to see all you can offer.
>> It's a matter of evolution and adaptation, Darwin. ;-)
>>
>> 
>
> Agree with PJ here:
> More likely, you go live and the boss says "Can you make that look more like 
> ...?"
> "Er, yes, but it totally stuffs the whole design..."
>
> Evolution was *not* carefully thought out - that would be Intelligent Design 
> 
>   
Chuckle, chuckle. ;-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] formatting - design question

2009-06-05 Thread Ford, Mike
On 04 June 2009 19:09, PJ advised:

> Nitsan Bin-Nun wrote:
>>> From my experience I tend to use a difference ID for the
> body tag, for
>> instance  and then format it in my CSS using ID
>> reference: #homepage .classname {
>>   color: blue;
>> }
>> 
>> This way you can use a default format for all the pages and create
minor
>> (or major) changes in the theme in no time :)
>> 
>> I would also suggest to attach the CSS filename reference at the

>> tag the update time of the file, so that the browser will
automatically
>> update the cache of the CSS whenever you decide to edit it.
>> 
>> Just my 2 cents ;)
>> 
> Oh, I think it's worth a lot more than that.
> I just installed IE 8 just to have it for verification. It's no better
> than IE 6. I never use them personally.
> But how do you produce interesting web pages to look well on both
> without making stupid compromises. What looks well on Firefox, looks
like
> MSshit on IE. 

This may be a silly question, but reading this just makes me wonder --
you do have an appropriate http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-05 Thread tedd

At 10:23 AM +0100 6/5/09, Peter Ford wrote:

PJ wrote:
 > tedd wrote:
 >> First you figure out a layout, then you populate it. You don't pick a
 >> layout, populate it and then change the layout.
 >>

 If only it were that simple.
 When one is developing, one is always changing. And even when you're
 finally "live and on the air", you will still be changing or else your
 site will die before your client gets a chance to see all you can offer.
 It's a matter of evolution and adaptation, Darwin. ;-)



Agree with PJ here:
More likely, you go live and the boss says "Can you make that look 
more like ...?"

"Er, yes, but it totally stuffs the whole design..."


If your Boss wants you to "test out" designs for his approval, that's 
one thing. I see no problem with a "Let's see what this might look 
like?" initial design decisions -- after all, he's paying for your 
time.


However, IMO his buck would be better spent if he hired a designer to 
design something around the needs of the project. I understand that 
sometimes "Bosses" aren't the brightest lot when it comes to things 
outside of their job description. But it is also your charge to 
explain the change asked for "totally stuffs the whole design..." If 
your Boss doesn't care about cost overruns in development, then start 
studying for his position because his boss does.


I am addressing what to do with clients who change their minds on 
agreed layouts.


My practice is the client decides on a layout that fits their needs 
before any development is done. If the client wants to change their 
mind in the middle of the development stage, that's fine -- but they 
will also pay for that change.


In my book, the "best" way to design a site is to: 1) decide what 
functionality is needed; 2) and then design a layout that presents 
the functionality in an attractive and accessible manner.


Creating a site is a lot like programming. The time spent identifying 
the problem will: a) shorten the overall time required to create a 
solution; b) and will also provide a more stable solution.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-05 Thread tedd

At 4:54 PM -0400 6/4/09, PJ wrote:

tedd wrote:
 > That's simply an example of not thinking things out before you write

 the code.

 First you figure out a layout, then you populate it. You don't pick a

 > layout, populate it and then change the layout.
 >
 >
If only it were that simple.
When one is developing, one is always changing. And even when you're
finally "live and on the air", you will still be changing or else your
site will die before your client gets a chance to see all you can offer.
It's a matter of evolution and adaptation, Darwin. ;-)


I understand clients changing their minds in mid-stream and wanting 
things to be different. That's Okay, because they pay for it -- 
PROVIDED -- that a meeting of the minds was made with the last layout.


So, before any change is made to the current layout, an agreement 
must be made as to what that change is going to be. Anything else 
(i.e., let's see if I like it) is going to be very time consuming on 
your part.


Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-05 Thread Peter Ford
PJ wrote:
> tedd wrote:
>> At 3:58 PM -0400 6/4/09, PJ wrote:
>>> tedd wrote:
>>>
>>>  > Style sheets are meant simplify things so decide on how you want
  things to look uniformly throughout your site and then stick with it.
  There's really no good reason to keep changing things throughout a
 site.

  Cheers,

  tedd


>>> Maybe I'm just too complicated. ;-)
>>> I do try to keep it simple. But then, little things creep in, like a
>>> login box on the index page which mucks up all the other pages. Then
>>> there is a recipe page which is totally different, yet to keep is
>>> stylistically continuous it uses a similar layout to the other pages but
>>> different. The same for the main recipe page, and the same for the
>>> portraits of producers - all the pages are different yet remain within a
>>> cohesive style. CSS gets super bloated and almost unamageable. Most
>>> sites are very repetitive; mine tend to be "provocative" or semthing
>>> like that. I really don't see an ooption. Although, Nitsan's body tags
>>> sound promising. I'll have to try that; maybe the solution is to do a
>>> series of definitions unique just fo certain pages. :-)
>> That's simply an example of not thinking things out before you write
>> the code.
>>
>> First you figure out a layout, then you populate it. You don't pick a
>> layout, populate it and then change the layout. That leads to a
>> lackluster and "lack of thought" site.
>>
>> Cheers,
>>
>> tedd
>>
>>
> If only it were that simple.
> When one is developing, one is always changing. And even when you're
> finally "live and on the air", you will still be changing or else your
> site will die before your client gets a chance to see all you can offer.
> It's a matter of evolution and adaptation, Darwin. ;-)
> 

Agree with PJ here:
More likely, you go live and the boss says "Can you make that look more like 
...?"
"Er, yes, but it totally stuffs the whole design..."

Evolution was *not* carefully thought out - that would be Intelligent Design 



-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread PJ
tedd wrote:
> At 3:58 PM -0400 6/4/09, PJ wrote:
>> tedd wrote:
>>
>>  > Style sheets are meant simplify things so decide on how you want
>>>  things to look uniformly throughout your site and then stick with it.
>>>  There's really no good reason to keep changing things throughout a
>>> site.
>>>
>>>  Cheers,
>>>
>>>  tedd
>>>
>>>
>> Maybe I'm just too complicated. ;-)
>> I do try to keep it simple. But then, little things creep in, like a
>> login box on the index page which mucks up all the other pages. Then
>> there is a recipe page which is totally different, yet to keep is
>> stylistically continuous it uses a similar layout to the other pages but
>> different. The same for the main recipe page, and the same for the
>> portraits of producers - all the pages are different yet remain within a
>> cohesive style. CSS gets super bloated and almost unamageable. Most
>> sites are very repetitive; mine tend to be "provocative" or semthing
>> like that. I really don't see an ooption. Although, Nitsan's body tags
>> sound promising. I'll have to try that; maybe the solution is to do a
>> series of definitions unique just fo certain pages. :-)
>
> That's simply an example of not thinking things out before you write
> the code.
>
> First you figure out a layout, then you populate it. You don't pick a
> layout, populate it and then change the layout. That leads to a
> lackluster and "lack of thought" site.
>
> Cheers,
>
> tedd
>
>
If only it were that simple.
When one is developing, one is always changing. And even when you're
finally "live and on the air", you will still be changing or else your
site will die before your client gets a chance to see all you can offer.
It's a matter of evolution and adaptation, Darwin. ;-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread tedd

At 3:58 PM -0400 6/4/09, PJ wrote:

tedd wrote:

 > Style sheets are meant simplify things so decide on how you want

 things to look uniformly throughout your site and then stick with it.
 There's really no good reason to keep changing things throughout a site.

 Cheers,

 tedd



Maybe I'm just too complicated. ;-)
I do try to keep it simple. But then, little things creep in, like a
login box on the index page which mucks up all the other pages. Then
there is a recipe page which is totally different, yet to keep is
stylistically continuous it uses a similar layout to the other pages but
different. The same for the main recipe page, and the same for the
portraits of producers - all the pages are different yet remain within a
cohesive style. CSS gets super bloated and almost unamageable. Most
sites are very repetitive; mine tend to be "provocative" or semthing
like that. I really don't see an ooption. Although, Nitsan's body tags
sound promising. I'll have to try that; maybe the solution is to do a
series of definitions unique just fo certain pages. :-)


That's simply an example of not thinking things out before you write the code.

First you figure out a layout, then you populate it. You don't pick a 
layout, populate it and then change the layout. That leads to a 
lackluster and "lack of thought" site.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread PJ
tedd wrote:
> At 2:08 PM -0400 6/4/09, PJ wrote:
>> Nitsan Bin-Nun wrote:
>>>  >From my experience I tend to use a difference ID for the body tag,
>>> for
>>>  instance  and then format it in my CSS using ID
>>>  reference:
>>>  #homepage .classname {
>>>color: blue;
>>>  }
>>>
>>>  This way you can use a default format for all the pages and create
>>> minor (or
>>>  major) changes in the theme in no time :)
>>>
>>>  I would also suggest to attach the CSS filename reference at the
>>>  tag
>>>  the update time of the file, so that the browser will automatically
>>> update
>>>  the cache of the CSS whenever you decide to edit it.
>>>
>>>  Just my 2 cents ;)
>>>  
>> Oh, I think it's worth a lot more than that.
>> I just installed IE 8 just to have it for verification. It's no better
>> than IE 6. I never use them personally.
>> But how do you produce interesting web pages to look well on both
>> without making stupid compromises. What looks well on Firefox, looks
>> like MSshit on IE.
>
> The way you do it is to keep it simple.
>
> If you use a different style sheet for every page, then not only does
> that cause more load times, but it confuses the Hell out of things, in
> my opinion.
>
> Style sheets are meant simplify things so decide on how you want
> things to look uniformly throughout your site and then stick with it.
> There's really no good reason to keep changing things throughout a site.
>
> Cheers,
>
> tedd
>
>
Maybe I'm just too complicated. ;-)
I do try to keep it simple. But then, little things creep in, like a
login box on the index page which mucks up all the other pages. Then
there is a recipe page which is totally different, yet to keep is
stylistically continuous it uses a similar layout to the other pages but
different. The same for the main recipe page, and the same for the
portraits of producers - all the pages are different yet remain within a
cohesive style. CSS gets super bloated and almost unamageable. Most
sites are very repetitive; mine tend to be "provocative" or semthing
like that. I really don't see an ooption. Although, Nitsan's body tags
sound promising. I'll have to try that; maybe the solution is to do a
series of definitions unique just fo certain pages. :-)

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread tedd

At 2:08 PM -0400 6/4/09, PJ wrote:

Nitsan Bin-Nun wrote:

 >From my experience I tend to use a difference ID for the body tag, for
 instance  and then format it in my CSS using ID
 reference:
 #homepage .classname {
   color: blue;
 }

 This way you can use a default format for all the pages and create minor (or
 major) changes in the theme in no time :)

 I would also suggest to attach the CSS filename reference at the  tag
 the update time of the file, so that the browser will automatically update
 the cache of the CSS whenever you decide to edit it.

 Just my 2 cents ;)
 

Oh, I think it's worth a lot more than that.
I just installed IE 8 just to have it for verification. It's no better
than IE 6. I never use them personally.
But how do you produce interesting web pages to look well on both
without making stupid compromises. What looks well on Firefox, looks
like MSshit on IE.


The way you do it is to keep it simple.

If you use a different style sheet for every page, then not only does 
that cause more load times, but it confuses the Hell out of things, 
in my opinion.


Style sheets are meant simplify things so decide on how you want 
things to look uniformly throughout your site and then stick with it. 
There's really no good reason to keep changing things throughout a 
site.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread PJ
Nitsan Bin-Nun wrote:
> >From my experience I tend to use a difference ID for the body tag, for
> instance  and then format it in my CSS using ID
> reference:
> #homepage .classname {
>   color: blue;
> }
>
> This way you can use a default format for all the pages and create minor (or
> major) changes in the theme in no time :)
>
> I would also suggest to attach the CSS filename reference at the  tag
> the update time of the file, so that the browser will automatically update
> the cache of the CSS whenever you decide to edit it.
>
> Just my 2 cents ;)
>   
Oh, I think it's worth a lot more than that.
I just installed IE 8 just to have it for verification. It's no better
than IE 6. I never use them personally.
But how do you produce interesting web pages to look well on both
without making stupid compromises. What looks well on Firefox, looks
like MSshit on IE.

-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-
Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread Nitsan Bin-Nun
>From my experience I tend to use a difference ID for the body tag, for
instance  and then format it in my CSS using ID
reference:
#homepage .classname {
  color: blue;
}

This way you can use a default format for all the pages and create minor (or
major) changes in the theme in no time :)

I would also suggest to attach the CSS filename reference at the  tag
the update time of the file, so that the browser will automatically update
the cache of the CSS whenever you decide to edit it.

Just my 2 cents ;)

--
Nitsan

On Thu, Jun 4, 2009 at 7:20 PM, Shawn McKenzie  wrote:

> Andrew Ballard wrote:
> > On Thu, Jun 4, 2009 at 12:54 PM, PJ  wrote:
> >> This may not be strictly php but I think is may be relevant.
> >> Were I to use a different css file for every page (that is slightly
> >> different), would that affect performance?
> >> It seems to me that might be a way of simplifying and certainly speeding
> >> up development (design-wise, anyway) when using css. A different css
> >> file for different pages would certainly make it a breeze to design a
> >> page; otherwise it is hell to try to put all formatting in one file - it
> >> even tends to get fairly bloated and difficult to follow your own
> shadow.
> >>
> >> --
> >> Hervé Kempf: "Pour sauver la plančte, sortez du capitalisme."
> >> -
> >> Phil Jourdan --- p...@ptahhotep.com
> >>   http://www.ptahhotep.com
> >>   http://www.chiccantine.com/andypantry.php
> >>
> >>
> >
> > It might be simpler during development, but YSlow! recommends putting
> > them in as few pages as is practical so the browser has fewer
> > resources to fetch and can make better use of caching. It won't affect
> > the speed of your PHP pages, but it should speed up the overall
> > download time of your pages from the end-user's perspective.
> >
> > Andrew
>
> I would have one main file that holds common styles and then if you need
> one, a page specific style sheet. You can even add all styles to the
> first and then override them in the second.  This is how they were
> intended to be used.  Also, most times the style sheets will be cached
> by the browser so only the first page load should matter.
>
> /* style sheet 1 */
> .someclass { color: red; }
> /* style sheet 2 */
> .someclass { color: blue }
>
> someclass will be blue.
>
> /* style sheet 1 */
> .someclass { color: red; }
> /* style sheet 2 */
> .someclass { color: blue; background-color: yellow; }
>
> /* style sheet 1 */
> .someclass { color: red; }
> /* style sheet 3 */
> .someclass { color: blue; background-color: white; }
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] formatting - design question

2009-06-04 Thread Shawn McKenzie
Andrew Ballard wrote:
> On Thu, Jun 4, 2009 at 12:54 PM, PJ  wrote:
>> This may not be strictly php but I think is may be relevant.
>> Were I to use a different css file for every page (that is slightly
>> different), would that affect performance?
>> It seems to me that might be a way of simplifying and certainly speeding
>> up development (design-wise, anyway) when using css. A different css
>> file for different pages would certainly make it a breeze to design a
>> page; otherwise it is hell to try to put all formatting in one file - it
>> even tends to get fairly bloated and difficult to follow your own shadow.
>>
>> --
>> Hervé Kempf: "Pour sauver la plančte, sortez du capitalisme."
>> -
>> Phil Jourdan --- p...@ptahhotep.com
>>   http://www.ptahhotep.com
>>   http://www.chiccantine.com/andypantry.php
>>
>>
> 
> It might be simpler during development, but YSlow! recommends putting
> them in as few pages as is practical so the browser has fewer
> resources to fetch and can make better use of caching. It won't affect
> the speed of your PHP pages, but it should speed up the overall
> download time of your pages from the end-user's perspective.
> 
> Andrew

I would have one main file that holds common styles and then if you need
one, a page specific style sheet. You can even add all styles to the
first and then override them in the second.  This is how they were
intended to be used.  Also, most times the style sheets will be cached
by the browser so only the first page load should matter.

/* style sheet 1 */
.someclass { color: red; }
/* style sheet 2 */
.someclass { color: blue }

someclass will be blue.

/* style sheet 1 */
.someclass { color: red; }
/* style sheet 2 */
.someclass { color: blue; background-color: yellow; }

/* style sheet 1 */
.someclass { color: red; }
/* style sheet 3 */
.someclass { color: blue; background-color: white; }

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting - design question

2009-06-04 Thread Andrew Ballard
On Thu, Jun 4, 2009 at 12:54 PM, PJ  wrote:
> This may not be strictly php but I think is may be relevant.
> Were I to use a different css file for every page (that is slightly
> different), would that affect performance?
> It seems to me that might be a way of simplifying and certainly speeding
> up development (design-wise, anyway) when using css. A different css
> file for different pages would certainly make it a breeze to design a
> page; otherwise it is hell to try to put all formatting in one file - it
> even tends to get fairly bloated and difficult to follow your own shadow.
>
> --
> Hervé Kempf: "Pour sauver la plančte, sortez du capitalisme."
> -
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>

It might be simpler during development, but YSlow! recommends putting
them in as few pages as is practical so the browser has fewer
resources to fetch and can make better use of caching. It won't affect
the speed of your PHP pages, but it should speed up the overall
download time of your pages from the end-user's perspective.

Andrew

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting output

2007-06-11 Thread Stut

[EMAIL PROTECTED] wrote:

I would like to format the output of a PHP page into a single line and use
gzip compression too.

I know that i can use something like this to get in a single line ( will
workout on this function later to remove spaces ).



And gzip compression is used with



Is there a way to "mix" those codes?


Output buffers can be stacked. So simply start the gzip bugger with 
ob_start, then call it again with your handler. The handlers will be 
called in reverse order when the buffers get flushed.


BTW, you don't need to ob_end_flush at the end of a script - this gets 
done automagically when the script ends.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting time :/

2007-01-02 Thread Richard Lynch
If it is stored in a database, you may want to convert within your query:
MySQL: date_format
Postgresql: to_char

If it's just in a text file, PHP's date() function should do it:
http://php.net/date

I dunno if there's a nifty constant for the format you want, but you
could always mess with mktime and date to get what you want.
http://php.net/mktime

On Tue, January 2, 2007 6:39 am, Steven Macintyre wrote:
> Hi all,
>
> I am unable to find out how to do this ... or what the format is
> "called"
> bar zulu format
>
> I have standard 00:00:00 time stored ... and wish to display it as
> 00h00 ...
> has anyone done this with php ... can you point me to right page etc
> ...
>
> What is that format called?
>
>
>
> Kind Regards,
>
>
> Steven Macintyre
> http://steven.macintyre.name
> --
>
> http://www.friends4friends.co.za
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting time :/

2007-01-02 Thread Steven Macintyre
Thanks Stut,

Perfect!


Kind Regards,


Steven Macintyre
http://steven.macintyre.name
--

http://www.friends4friends.co.za


> -Original Message-
> From: Stut [mailto:[EMAIL PROTECTED]
> Sent: 02 January 2007 02:59 PM
> To: Steven Macintyre
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] Formatting time :/
> 
> Steven Macintyre wrote:
> > I am unable to find out how to do this ... or what the format is
> "called"
> > bar zulu format
> >
> > I have standard 00:00:00 time stored ... and wish to display it
> as 00h00 ...
> > has anyone done this with php ... can you point me to right page
> etc ...
> >
> > What is that format called?
> 
> http://php.net/date
> 
> $time = date('H\hi', strtotime('00:00:00'));
> 
> Or, if the input format is always the same, you could do it like
> so...
> 
> $time = str_replace(':', 'h', substr('00:00:00', 0, 5));
> 
> -Stut
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting time :/

2007-01-02 Thread Stut

Steven Macintyre wrote:

I am unable to find out how to do this ... or what the format is "called"
bar zulu format

I have standard 00:00:00 time stored ... and wish to display it as 00h00 ...
has anyone done this with php ... can you point me to right page etc ...

What is that format called?


http://php.net/date

$time = date('H\hi', strtotime('00:00:00'));

Or, if the input format is always the same, you could do it like so...

$time = str_replace(':', 'h', substr('00:00:00', 0, 5));

-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Question

2006-10-05 Thread Toby Osbourn

Thanks to everyone for their suggestions, I used the nl2br function in the
end, and it works perfectly.

On 02/10/06, Richard Lynch <[EMAIL PROTECTED]> wrote:


On Mon, October 2, 2006 4:13 pm, tedd wrote:
> Why not use nl2br() to show the data in the browser and leave the
> data "as-is" in the dB?

Apparently I typed too much, cuz that's exactly what I said, or meant
to say...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?





--
http://www.borninblood.co.uk


Re: [PHP] Formatting Question

2006-10-02 Thread Richard Lynch
On Mon, October 2, 2006 4:13 pm, tedd wrote:
> Why not use nl2br() to show the data in the browser and leave the
> data "as-is" in the dB?

Apparently I typed too much, cuz that's exactly what I said, or meant
to say...

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Question

2006-10-02 Thread tedd

At 3:51 PM -0500 10/2/06, Richard Lynch wrote:

Don't "pollute" your raw data (the newlines) with a very
media-specific formatting code ("") -- Keep your raw data pure
and clean, and format for the destination when you send it there, not
when you store it.
There *might* be some egregious examples of over-loaded high-volume
servers where adding the "" at run-time is "too much work" -- At
that point, it's probably still not the "Right Answer" to pollute the
raw data.  It might be expensive, but adding a cache of the output
data, or even a second field for data_as_html to the database should
be considered.  Anything other than polluting your raw data.

This may seem high-falutin' purism, but it will make your life so
much more pleasant some day down the road.


Richard:

You are absolutely right of course -- don't pollute your raw data.

Why not use nl2br() to show the data in the browser and leave the 
data "as-is" in the dB?


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Question

2006-10-02 Thread Richard Lynch
On Mon, October 2, 2006 12:08 pm, Toby Osbourn wrote:
> Sorry to plague you with a question that should have a simple answer,
> but I
> can't find said answer anywhere (probably looking for the wrong things
> in
> the wrong places!)
>
> Basically I want to allow a user to input a string via a form into a
> database, I have the code to do that and it works almost 100% - I have
> made
> it so that any html tags are stripping off the string before saving
> it, but
> I do want to allow some basic formatting - namely when a user takes a
> new
> line in the textbox, I want the new line to carry over to the
> database.
>
> At the moment the user could type in something like this...
>
> wibble
> wobble
>
> But after it has been submitted and then retrieved from the database
> it will
> return wibblewobble.

You may THINK you are seeing "wibble wobble" in your browser, but
that's because a browser smushes all whitespace into just one
whitespace -- that's why you need   all over the place in the Bad
Old Days... :-)

Anyway, you could be managing to strip out the newlines, I suppose, in
which case you have to figure out where you are doing that.

Echo out the data as it travels into/through/out-of your system.

echo ""; htmlentities($whatever); "";

For removing the HTML, use http://php.net/striptags

For ancient browsers that give non-standard newlines do like this with
the input:
$text = str_replace("\r\n", "\n", $text); //non-standard Windows browsers
$text = str_replace("\r", "\n", $text); //non-standard Mac browsers

Then, on *OUTPUT* to a browser, only on output to a browser, you can
use http://php.net/nl2br to format the newlines for HTML.

The reason for doing this only on output is this:
Some day, even if you don't think you will, you *might* need to output
this to someting other than a browser.  RSS, CSV dump, or some new
fancy format we haven't even invented yet.

Don't "pollute" your raw data (the newlines) with a very
media-specific formatting code ("") -- Keep your raw data pure
and clean, and format for the destination when you send it there, not
when you store it.

There *might* be some egregious examples of over-loaded high-volume
servers where adding the "" at run-time is "too much work" -- At
that point, it's probably still not the "Right Answer" to pollute the
raw data.  It might be expensive, but adding a cache of the output
data, or even a second field for data_as_html to the database should
be considered.  Anything other than polluting your raw data.

This may seem high-falutin' purism, but it will make your life so
much more pleasant some day down the road.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Question

2006-10-02 Thread tedd

At 6:08 PM +0100 10/2/06, Toby Osbourn wrote:

Sorry to plague you with a question that should have a simple answer, but I
can't find said answer anywhere (probably looking for the wrong things in
the wrong places!)

Basically I want to allow a user to input a string via a form into a
database, I have the code to do that and it works almost 100% - I have made
it so that any html tags are stripping off the string before saving it, but
I do want to allow some basic formatting - namely when a user takes a new
line in the textbox, I want the new line to carry over to the database.

At the moment the user could type in something like this...

wibble
wobble

But after it has been submitted and then retrieved from the database it will
return wibblewobble.

Any ideas?

Regards

Toby


Toby:

Ideas?

After stripping html,

$txt = str_replace("\n","",$txt);
$txt = str_replace("\r","",$txt);

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting Question

2006-10-02 Thread Dave Goodchild

How is the field set in the database - is it CHAR/VARCHAR or TEXT?







--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk


Re: [PHP] Formatting a Time field

2006-03-23 Thread Richard Lynch
On Thu, March 23, 2006 5:51 pm, Todd Cary wrote:
> I have a field, Start_Time, in a MySQL DB.  Since it is not a
> TimeStamp, I believe I cannot use date(), correct?
>
> I would like to format 09:00:00 to 9:00 AM.
>
> If I convert the 09:00:00 with the strtotime(), I get a couple of
> extra minutes added.

You may be able to convince MySQL to convert it with a function from
http://mysql.com (hint: search for convert) and that might give much
more satisfactory results.

You should also consider biting the bullet and converting the field to
a real 'Time' type.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting a Time field

2006-03-23 Thread Tom Rogers
Hi,

Friday, March 24, 2006, 9:51:48 AM, you wrote:
TC> I have a field, Start_Time, in a MySQL DB.  Since it is not a 
TC> TimeStamp, I believe I cannot use date(), correct?

TC> I would like to format 09:00:00 to 9:00 AM.

TC> If I convert the 09:00:00 with the strtotime(), I get a couple of 
TC> extra minutes added.

TC> Suggestions are welcomed

TC> Todd


use gmdate() to do the formatting. in strtotime you should give a date something
like
$ftime = gmdate('h:i A',strtotime("2000-01-01 $Start_Time"));

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting of a number

2005-11-16 Thread David Grant
Hi Scott,

How do you distinguish between a value filled with zeroes and a value
with 0 in both decimal positions?

For example, why is 3145900 expressed as 3,145.90, and not 31,459.00?

Cheers,

David Grant

Scott Parks wrote:
> Hi-
> 
> I have a number that I am trying to format.  It is data coming from a
> main frame and
> has 8 characters assigned to it (6 and two decimal places).  I have
> zerofill set up in
> MySQL on this field and am working on the best way to display the number.
> 
> Currently I have this:
> 
> $sOutput = number_format(rtrim($sValue,'0') /100,2);
> 
> What I am running into is this, I have a number in this field as:
> 3145900, using the above I will get:  314.59, which is wrong, it
> needs to be 3,145.90.
> 
> Yet, if I have a number of:  749450, I get the result I am looking for
> of 749.45.
> 
> I did not see a way to tell trim I only want one 0 cut?
> 
> Any thoughts?
> 
> Thank you!
> 
> -Scott
> 
> --PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting problems:

2005-08-16 Thread Ryan A

On 8/16/2005 9:59:30 PM, Scott Noyes ([EMAIL PROTECTED]) wrote:
> It's not clear to me how strict you want to be regarding the
> formatting.  Are you trying to keep scenes together on each line, or
> just dump everything and let it wrap where it needs to?  Perhaps you
> could handcode a sample and post a link.  I'd
> also guess that you
> could make good use of CSS, specifically the "float: left" and
> clear=all attributes.



Hey,
Thanks for replying.

basically I want this part to keep looping:

  
 
 
 
  

(Below I am attaching the whole code again so you can see)

To see the format I am after click here:
www.ezee.se/format.htm

Thanks,
Ryan















  
Title
 
  
  
cover pic 

  
Scenes
Length
Format
  
  
 
 
 
  

  
\n\n\n\n\n\n\n\n\n";
  }
 $flick_name2 = $flick_name;
 }



?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting problems:

2005-08-16 Thread Scott Noyes
It's not clear to me how strict you want to be regarding the
formatting.  Are you trying to keep scenes together on each line, or
just dump everything and let it wrap where it needs to?  Perhaps you
could handcode a sample and post a link.  I'd also guess that you
could make good use of CSS, specifically the "float: left" and
clear=all attributes.


> My database has a table called movies which has data like this:
> 
> flick_name ,flick_cover, part_url
> 
> flick_name is the name of the movie, the movie is cut into several pieces
> for faster downloads
> part_url is the full path to each of the pieces
> 
> eg:
> home movie 1 ,a.gif, http://movieserver.com/scene1_1.wmv
> home movie 1 ,a.gif, http://movieserver.com/scene1_2.wmv
> home movie 1 ,a.gif, http://movieserver.com/scene1_3.wmv
> home movie 1 ,a.gif, http://movieserver.com/scene2_1.wmv
> home movie 1 ,a.gif, http://movieserver.com/scene2_2.wmv
> home movie 1 ,a.gif, http://movieserver.com/scene2_3.wmv
> etc
> 
> I am trying to get it into this format:
> http://www.ezee.se/format.jpg

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Philip Hallstrom

Good point.  Only problem is, if someone hit enter a-million times,
you would end up with a-million spaces where the "\n" characters were.
To take care of that repetition, maybe something like:


while (strpos($textarea_text, "\n\n")) {
.
}


would be one way you could do it.


$new_str = ereg_replace("[\n\r]+", " ", $textarea_text);

would be another and avoid the loop as well at the expense of adding some 
regexps :)






On 6/13/05, Murray @ PlanetThoughtful <[EMAIL PROTECTED]> wrote:

Use the PHP str_replace function before writing it to the DB.  Replace
all "\n" characters with an empty string "".

http://us2.php.net/manual/en/function.str-replace.php


I think it might be better to replace all "\n" characters with spaces " ",
otherwise you will end up with sentences that have no space break between
them.

Ie:


This is the first sentence.

This is the second sentence.


...would become:


This is the first sentence.This is the second sentence.


Regards,

Murray

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Richard Lynch
On Mon, June 13, 2005 12:06 pm, Paul Nowosielski said:
>  I'm having a perplexing problem. I'm gather data through a 
> html from field and dumping it to MySQL.
>
>  I want to display the data as a long string with no carriage returns or
> line breaks in a dhtml div window.

What styles have you applied to the div and surrounding elements?

> The problem I'm have is that the form data is remembering the carriage
> returns. I tried using trim() and rtrim() with no luck. The data is
> still formatted exactly like it was inputed.

That sounds like PRE tag (or 'pre' style) or perhaps http://php.net/nl2br
is being used when you don't really want that.

> Any ideas why this is happening and how I can format the text properly??

Show us actual output, like a URL for better guesses.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting paragraphs in to strings

2005-06-13 Thread John Browne
Right..  But the browser also should be ignoring the carriage returns
as well, which makes me think the div is set to "white-space: pre;" or
something.  He said the text is being formatted in a div exactly how
it is entered into the system.  By default, a div does not render any
carriage returns.


On 6/13/05, Murray @ PlanetThoughtful <[EMAIL PROTECTED]> wrote:
> > Good point.  Only problem is, if someone hit enter a-million times,
> > you would end up with a-million spaces where the "\n" characters were.
> >  To take care of that repetition, maybe something like:
> >
> >
> > while (strpos($textarea_text, "\n\n")) {
> >  .
> > }
> >
> >
> > would be one way you could do it.
> 
> Ordinarily most browsers render multiple consecutive spaces as a single
> space. This doesn't mean that it's not a good idea to remove them, just that
> not doing so shouldn't effect the way the text is displayed in the div tag,
> as the original poster mentioned was his intention.
> 
> Regards,
> 
> Murray
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Murray @ PlanetThoughtful
> Good point.  Only problem is, if someone hit enter a-million times,
> you would end up with a-million spaces where the "\n" characters were.
>  To take care of that repetition, maybe something like:
> 
> 
> while (strpos($textarea_text, "\n\n")) {
>  .
> }
> 
> 
> would be one way you could do it.

Ordinarily most browsers render multiple consecutive spaces as a single
space. This doesn't mean that it's not a good idea to remove them, just that
not doing so shouldn't effect the way the text is displayed in the div tag,
as the original poster mentioned was his intention.

Regards,

Murray

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting paragraphs in to strings

2005-06-13 Thread John Browne
Good point.  Only problem is, if someone hit enter a-million times,
you would end up with a-million spaces where the "\n" characters were.
 To take care of that repetition, maybe something like:


while (strpos($textarea_text, "\n\n")) {
 .
}


would be one way you could do it.


On 6/13/05, Murray @ PlanetThoughtful <[EMAIL PROTECTED]> wrote:
> > Use the PHP str_replace function before writing it to the DB.  Replace
> > all "\n" characters with an empty string "".
> >
> > http://us2.php.net/manual/en/function.str-replace.php
> 
> I think it might be better to replace all "\n" characters with spaces " ",
> otherwise you will end up with sentences that have no space break between
> them.
> 
> Ie:
> 
> 
> This is the first sentence.
> 
> This is the second sentence.
> 
> 
> ...would become:
> 
> 
> This is the first sentence.This is the second sentence.
> 
> 
> Regards,
> 
> Murray
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] formatting paragraphs in to strings

2005-06-13 Thread Murray @ PlanetThoughtful
> Use the PHP str_replace function before writing it to the DB.  Replace
> all "\n" characters with an empty string "".
> 
> http://us2.php.net/manual/en/function.str-replace.php

I think it might be better to replace all "\n" characters with spaces " ",
otherwise you will end up with sentences that have no space break between
them.

Ie:


This is the first sentence.

This is the second sentence.


...would become:


This is the first sentence.This is the second sentence.


Regards,

Murray

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting paragraphs in to strings

2005-06-13 Thread John Browne
Use the PHP str_replace function before writing it to the DB.  Replace
all "\n" characters with an empty string "".

http://us2.php.net/manual/en/function.str-replace.php


On 6/13/05, Paul Nowosielski <[EMAIL PROTECTED]> wrote:
> Hi,
> 
>  I'm having a perplexing problem. I'm gather data through a 
> html from field and dumping it to MySQL.
> 
>  I want to display the data as a long string with no carriage returns or
> line breaks in a dhtml div window.
> 
> The problem I'm have is that the form data is remembering the carriage
> returns. I tried using trim() and rtrim() with no luck. The data is
> still formatted exactly like it was inputed.
> 
> Any ideas why this is happening and how I can format the text properly??
> 
> TIA!
> 
> 
> --
> Paul Nowosielski
> Webmaster CelebrityAccess.com
> 303.440.0666 ext:219
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting logic

2005-04-21 Thread Andy Pieters
Hi

First, execute your query

unset($fail);
$res=mysql_query($sql,$dbhandle) or $fail=true;
if( (isset($fail)) || (!(is_resource($res)) )
 echo "There was a problem with the execution of the query";
if(mysql_num_rows($res)==0)
 echo "The query resulted in ZERO records";

#now that's out of the way, start processing the records.  Since you ordered 
them by category already, just do like this

$oldcat='';
while($rec=mysql_fetch_assoc($res)
{if(!($oldcat==$rec['category']))
 {echo "Your category header here";
  $oldcat=$rec['category'];}
 echo "picture data here";}
if(is_resource($res))
 mysql_free_result($res);

>
> What am I missing?
>
The way to the php.net website.
http://www.php.net/


-- 
Registered Linux User Number 379093
-- --BEGIN GEEK CODE BLOCK-
Version: 3.1
GAT/O/>E$ d-(---)>+ s:(+)>: a--(-)>? C$(+++) UL>$ P-(+)>++
L+++>$ E---(-)@ W+++>+++$ !N@ o? !K? W--(---) !O !M- V-- PS++(+++)
PE--(-) Y+ PGP++(+++) t+(++) 5-- X++ R*(+)@ !tv b-() DI(+) D+(+++) G(+)
e>$@ h++(*) r-->++ y--()>
-- ---END GEEK CODE BLOCK--
--
Check out these few php utilities that I released
 under the GPL2 and that are meant for use with a 
 php cli binary:
 
 http://www.vlaamse-kern.com/sas/
--

--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting logic

2005-04-21 Thread Philip Hallstrom
I am allowing our members to upload pictures and they can choose which 
category the pictures go under, the first category "public" is made for 
them.

When I sql the DB I call it like this: select picture_names<,more 
fields> from  where member_id= order by category.

which i display something like this:
__
| pic-here |  | category here|
| pic-here |  | category here|
-
how can i display it like this:
__
category here|
-
| pic-here |  |
| pic-here |  |
__
category here|
-
| pic-here |  |
| pic-here |  |
-
I thought of just getting the categories into an array and then sqling 
on each category but if there are 30 user defined categories that would 
mean 30 queries Another more complicated way would be to get all the 
records and sort them into arrays via categories and child arrays...I 
just feel this is too complicated for the above job.
Keep your query like it is... and do something like this:
$current_category = "";
while ( $row = db_get_object_function($db_result) ) {
if ($current_category != $row->category) {
print("$row->category header goes here");
$current_category = $row->category;
}
print("pic-here stuff goes here");
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Formatting e-mail using mail()

2005-02-23 Thread Jochem Maas
Burhan Khalid wrote:
Jacques wrote:
Can I format an e-mail message with html tags inside the mail() 
function? If not, how can I go about it? I would like to format the 
layout of the e-mail message using tables, colors and perhaps images.

Please, FFS RTFM > http://www.php.net/manual/en/function.mail.php
and when your done brushing up on the mail function and related material
have a google for 'phpmailer' - a lovely class that abstracts out all the
headache stuff associated with formatting an email properly (headers, multi-part
MIME, boundaries, etc)
Tip: don't go stuffing HTML tagsoup into the body of an email mail()ing it. not
everyone likes html email - some can't read it [AOL users/email-apps are a 
nightmare]
its better to offer a plaintext version of the message as well as the singing 
and
dancing version (best/safest is to go purely plaintext but then again you 
probably
have one of those insistent marketing depts on you back ;-)
don't assume that because Outlook can view your html email as intended that 
other
programs can too! Another thing - if you intend to include images beware that 
there
are 2 ways to do it.
1 include the image file in the msg (make use of a 'cid:' src value for the IMG 
tag
in the HTML)
2. reference images that are on your public webserver this is way better it 
terms
of bnadwidth, sometimes there is a requirement for offline reading (in which 
case you
may have to embed the files instead)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Formatting e-mail using mail()

2005-02-22 Thread Burhan Khalid
Jacques wrote:
Can I format an e-mail message with html tags inside the mail() function? 
If not, how can I go about it? I would like to format the layout of the 
e-mail message using tables, colors and perhaps images.
Please, FFS RTFM > http://www.php.net/manual/en/function.mail.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] formatting a string

2004-04-24 Thread Andy B
[snip]
$phone = '1234567890';
$newphone = preg_replace('/(\d{3})(\d{3})(\d)/','(\1)\2-\3',$phone);
echo $newphone.'';

--
regards,
Tom
[/snip]
ok sorry but since i never used preg_* before i dont quite get what some of
this stuff means. i looked at the doc page for it but it doesnt make mention
at all of what \d, \w, \s or any of those things mean... i only assume that
\d means digit and \w or \s means blank space??

anyways to go through the whole example above part by part:
$phone = '1234567890';//understand that
$newphone = preg_replace(//ok now what does this stuff
//mean??
'/(\d{3})(\d{3})(\d)/'
im gathering the line above is the search string (what to look for)? if so i
get from it that it is supposed to look for the first block of 3 digits then
the second block of 3 digits and the other 4 numbers by themself in a sense
seperating the string into 3 different parts: 123 456 7890 and then asigning
like "id numbers to the blocks"
'(\1)\2-\3'
and this one above says put block 1 between (). take block 2 and put a -
after it and leave the other 4 numbers alone to come up with: (123)456-7890
$phone);
the original number to do the replace on of course

let me know if i got that set right

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] formatting a string

2004-04-24 Thread Tom Rogers
Hi,

Sunday, April 25, 2004, 11:17:16 AM, you wrote:
AB> hi...

AB> i have a string i want to pull out of a database (mysql). the column name is
AB> Phone1 and it is a 10 digit phone number. the raw string coming out of the
AB> table column would look like this: 1234567890

AB> what i want to do is format the string on display like this: (123)456-7890
AB> but dont quite know how to start with that. what function(s) would i use for
AB> that?


Try this:
$phone = '1234567890';
$newphone = preg_replace('/(\d{3})(\d{3})(\d)/','(\1)\2-\3',$phone);
echo $newphone.'';

-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting phone numbers?

2004-04-17 Thread Andy Crain
Jay,

> Here is a little more of the larger function with comments (more
> comments than code, which is never a Bad Thing [tm]). I am only showing
> the handling for two basic types of telephone numbers with explanation
> for additional verification which we would typically use, since we have
> those resources available.

Great. Thanks very much.
Andy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Jay Blanchard
[snip]
> [stuff you may not need]
> This is a boiled down version of a longer function that counts string
> lengths to determine how many dashes might need to be added. Let's say
> you have the area code in the number, like 2108765432. Being a ten
digit
> number with a recognizable area code we can then add a portion to the
> function to add the two needed dashes, making the number more
readable.
> [/stuff]

I'd love to see that larger function, if you care to share.
[/snip]

Here is a little more of the larger function with comments (more
comments than code, which is never a Bad Thing [tm]). I am only showing
the handling for two basic types of telephone numbers with explanation
for additional verification which we would typically use, since we have
those resources available.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Andy Crain
Good stuff.

> [stuff you may not need]
> This is a boiled down version of a longer function that counts string
> lengths to determine how many dashes might need to be added. Let's say
> you have the area code in the number, like 2108765432. Being a ten digit
> number with a recognizable area code we can then add a portion to the
> function to add the two needed dashes, making the number more readable.
> [/stuff]

I'd love to see that larger function, if you care to share.
Andy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Paul Fine
Thanks!



-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
Sent: April 16, 2004 7:33 AM
To: BOOT; [EMAIL PROTECTED]
Subject: RE: [PHP] Formatting phone numbers?

[snip]
Thanks for any help, even if you just suggest built in functions to look
at.

I'm looking for a way to take a 7 digit number and put it into xxx-
format.

So basically the logic is to count 3 characters into $number and insert
a
"-" there.
[/snip]

As a telecom we use several methods, but here is a small function which
allows us to keep both formats where needed

function addTNDashes ($oldNumber){
   $newNumber = substr($oldNumber, 0, 3) . "-" . substr($oldNumber, 3,
4);
   
   return $newNumber;
}

$telephone = "8654321";
$newTele = addTNDashes($telephone);
echo $newTele;

output is 865-4321 and we can still use $telephone if we need to. 
[stuff you may not need]
This is a boiled down version of a longer function that counts string
lengths to determine how many dashes might need to be added. Let's say
you have the area code in the number, like 2108765432. Being a ten digit
number with a recognizable area code we can then add a portion to the
function to add the two needed dashes, making the number more readable.
[/stuff]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting phone numbers?

2004-04-16 Thread Rob Ellis
On Thu, Apr 15, 2004 at 06:11:57PM -0400, John W. Holmes wrote:
> Rob Ellis wrote:
> >On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote:
> >>
> >>I'm looking for a way to take a 7 digit number and put it into xxx-
> >>format.
> >>
> >>So basically the logic is to count 3 characters into $number and insert a
> >>"-" there.
> >
> >substr_replace($string, '-', 3, 0);
> 
> Won't that replace the number, though, not insert the dash?

No, it does the right thing. The last 0 is the number of 
characters to replace.

- Rob

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting phone numbers?

2004-04-16 Thread Jay Blanchard
[snip]
Thanks for any help, even if you just suggest built in functions to look
at.

I'm looking for a way to take a 7 digit number and put it into xxx-
format.

So basically the logic is to count 3 characters into $number and insert
a
"-" there.
[/snip]

As a telecom we use several methods, but here is a small function which
allows us to keep both formats where needed

function addTNDashes ($oldNumber){
   $newNumber = substr($oldNumber, 0, 3) . "-" . substr($oldNumber, 3,
4);
   
   return $newNumber;
}

$telephone = "8654321";
$newTele = addTNDashes($telephone);
echo $newTele;

output is 865-4321 and we can still use $telephone if we need to. 
[stuff you may not need]
This is a boiled down version of a longer function that counts string
lengths to determine how many dashes might need to be added. Let's say
you have the area code in the number, like 2108765432. Being a ten digit
number with a recognizable area code we can then add a portion to the
function to add the two needed dashes, making the number more readable.
[/stuff]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting phone numbers?

2004-04-15 Thread John W. Holmes
Rob Ellis wrote:
On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote:
>>
I'm looking for a way to take a 7 digit number and put it into xxx-
format.
So basically the logic is to count 3 characters into $number and insert a
"-" there.
substr_replace($string, '-', 3, 0);
Won't that replace the number, though, not insert the dash?

$formatted_number = preg_replace('/^([0-9]{3})/,'\1-',$number);

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Formatting phone numbers?

2004-04-15 Thread Rob Ellis
On Thu, Apr 15, 2004 at 04:31:09PM -0500, BOOT wrote:
> Thanks for any help, even if you just suggest built in functions to look at.
> 
> I'm looking for a way to take a 7 digit number and put it into xxx-
> format.
> 
> So basically the logic is to count 3 characters into $number and insert a
> "-" there.

substr_replace($string, '-', 3, 0);

- Rob

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Formatting a string for entry into MySQL

2003-09-23 Thread James Johnson
Ok, thanks. It took a little bit of experimenting with printf(), sprintf()
and quotes, but I got it to work.

mysql_select_db($database_CCB, $CCB);
$ad_contact = "[EMAIL PROTECTED]909-555-1212";
$esAdContact = mysql_escape_string($ad_contact);
$q = sprintf("UPDATE subscriber_ads SET ad_contact = '%s' WHERE subid = 43",
$esAdContact);
$r = mysql_query($q, $CCB) or print(mysql_error()); 

Thanks,
James

-Original Message-
From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 23, 2003 4:45 AM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Formatting a string for entry into MySQL


James Johnson wrote:
> Hi,
> 
> I'm trying to generate a string that contains a , to insert into a 
> MySQL table. It appears the  is being stripped out either just 
> before or during the update.

http://www.php.net/mysql-escape-string

-- 
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting a string for entry into MySQL

2003-09-23 Thread Burhan Khalid
James Johnson wrote:
Hi,

I'm trying to generate a string that contains a , to insert into a MySQL
table. It appears the  is being stripped out either just before or
during the update.
http://www.php.net/mysql-escape-string

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Formatting an ascii characters in php?

2003-08-14 Thread Jay Blanchard
[snip]
I use the cURL to send and receive data regardless of what data
format
is the data in.  There are certian ascii characters in the data, like
'LF'
for line feed, 'CR' for carriage return, etc.  This time I came upon a
problem where one of those ascii character caused PHP to get tripped up.
So, is there any PHP function or script that can translate the ascii
character into a text format where I can read each of those character to
see
which one is causing the problem so I can be able to fix the problem.
Any
know of any of such PHP feature that can do those conversion?
[/snip]

http://us2.php.net/manual/en/function.ascii2ebcdic.php may help.

Have a pleasant and productive day!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ascii characters in php?

2003-08-14 Thread Curt Zirzow
* Thus wrote Scott Fletcher ([EMAIL PROTECTED]):
> Hi!
> 
> I use the cURL to send and receive data regardless of what data format
> is the data in.  There are certian ascii characters in the data, like 'LF'
> for line feed, 'CR' for carriage return, etc.  This time I came upon a
> problem where one of those ascii character caused PHP to get tripped up.
> So, is there any PHP function or script that can translate the ascii
> character into a text format where I can read each of those character to see
> which one is causing the problem so I can be able to fix the problem.  Any
> know of any of such PHP feature that can do those conversion?

You can read each char by walking through it like:

for ($i = 0; $i < strlen($str); $i++) {
  print ord($str[$i]);
}

that will print the ordinal value the characters in the string.


Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting an ascii characters in php?

2003-08-08 Thread Scott Fletcher
Thanks for the tips.  I did look into this webpage just the same one as you
provided in the link before I post a message in this newsgroup.  That
webpage said, "ascii2ebcdic() is an Apache-specific function which is
available only on EBCDIC based operating systems (OS/390, BS2000)."  Problem
is I don't have EDBCDIC based operating system.  But thanks...

Scott

"Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
I use the cURL to send and receive data regardless of what data
format
is the data in.  There are certian ascii characters in the data, like
'LF'
for line feed, 'CR' for carriage return, etc.  This time I came upon a
problem where one of those ascii character caused PHP to get tripped up.
So, is there any PHP function or script that can translate the ascii
character into a text format where I can read each of those character to
see
which one is causing the problem so I can be able to fix the problem.
Any
know of any of such PHP feature that can do those conversion?
[/snip]

http://us2.php.net/manual/en/function.ascii2ebcdic.php may help.

Have a pleasant and productive day!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Formatting issue.

2003-06-16 Thread Hugh Bothwell
"Lowell Allen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> From: "Tom Ray [Lists]" <[EMAIL PROTECTED]>
>>
>> I want to be
>> able to display thumbnail versions of the pictures, 3 per row and as
>> many rows as needed. Unfortunetly, all I can do right now is 1 per row,
>> this is where I need the help. Here's the code that displays images:
>> [snip]
>> So how do I make this work so I can have three cells per table row and
>> it actaully show the proper picture?
>
>
> You need to set up a counter so you can start a new table row at the
> appropriate time. Beginning from the line where you use explode(), and for
> brevity not writing out the HTML for linking the image:


... alternatively, you could use CSS relative positioning to
'flow' the images, so they wrap to whatever the page width
is.

This has the side benefits of simplifying your output
logic and making the output more flexible.




--
Hugh Bothwell [EMAIL PROTECTED] Kingston ON Canada
v3.1 GCS/E/AT d- s+: a- C+++ L++>+++$ P+ E- W+++$ N++ K? w++ M PS+
PE++ Y+ PGP+ t-- 5++ !X R+ tv b DI+++ D-(++) G+ e(++) h-- r- y+




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   >