Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 10th, 2005, 12:13 PM
Authorized User
Points: 138, Level: 2
Points: 138, Level: 2 Points: 138, Level: 2 Points: 138, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: McHenry, IL, .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Best way to convert '\t' to TAB character?

Hi,
What's the best way to convert '\t' to a tab character ("\t")?
For example, what's the best way to convert $sq_tab, below, to make the print statement display the same on both sides of the '==='?:

$sq_tab = '\t';
$dq_tab = "\t";
$str = "($sq_tab) === ($dq_tab)";
print $str;


Philibuster
__________________
Philibuster
Reply With Quote
  #2 (permalink)  
Old January 10th, 2005, 03:24 PM
Authorized User
 
Join Date: Dec 2004
Location: Tunkhannock, PA, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

if ($sq_tab == '\t') $sq_tab = "\t";


Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
Reply With Quote
  #3 (permalink)  
Old January 10th, 2005, 04:25 PM
Authorized User
Points: 138, Level: 2
Points: 138, Level: 2 Points: 138, Level: 2 Points: 138, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: McHenry, IL, .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Paul,
TNX for your answer. Do you have a more general solution for this problem which can handle any escaped character (i.e., /t,/r,/n, etc.)? I don't know of any generic PHP functionality that does this sort of escape character handling - do you?

Philibuster
Reply With Quote
  #4 (permalink)  
Old January 10th, 2005, 04:33 PM
Authorized User
 
Join Date: Dec 2004
Location: Tunkhannock, PA, USA.
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

Are you trying to do a comparison of these functions? or are you attempting to do something that allows user input that you can (somewhat) control?

There are functions in php that allow you to do some conversions.

i.e.
  nl2br()
  htmlspecialchars()
  htmlentities()
  wordwrap()
  str_replace()
  etc....

Can start at http://us3.php.net/nl2br and there are links to the others from there.

I could give a better answer if I understood better what it was you are trying to do.




Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
Reply With Quote
  #5 (permalink)  
Old January 10th, 2005, 05:05 PM
Authorized User
Points: 138, Level: 2
Points: 138, Level: 2 Points: 138, Level: 2 Points: 138, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2004
Location: McHenry, IL, .
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I provide the user with a way to enter a delimeter character of choice including escaped characters in a form text box. It would be awkward for the user to specify the delimeter via the HTML equiv. escape character (i.e. &xxx;) so I'm allowing for the usual /t, /n, /r type of delimeters. Unfortunately, the text is returned as a literal string (same as '/t', etc.). Although functions such as html_entity_decode() will convert HTML character entities within a literal string (such as '&amp', '&gt', etc. - I don't know of an equivalent function that will handle '/t', '/r', etc. I could write a function - but I thought someone would have a more elegant answer. Any ideas?


Philibuster
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to disable a tab on a tab control. dbradley VB.NET 6 April 14th, 2011 10:04 AM
how do I convert character to utf hex code? mondayisgreat Classic ASP Basics 1 January 24th, 2008 01:48 PM
Convert special character for text view mussitsch Classic ASP Professional 0 October 26th, 2006 11:13 AM
How to convert UTF8 code to character ghostnguyen C# 1 July 18th, 2005 05:28 AM
HTML has no [b]tab[/b] character? anshul HTML Code Clinic 2 May 22nd, 2005 08:28 AM



All times are GMT -4. The time now is 10:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.