Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 10th, 2005, 12:13 PM
Authorized User
 
Join Date: Dec 2004
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
 
Old January 10th, 2005, 03:24 PM
Authorized User
 
Join Date: Dec 2004
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
 
Old January 10th, 2005, 04:25 PM
Authorized User
 
Join Date: Dec 2004
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
 
Old January 10th, 2005, 04:33 PM
Authorized User
 
Join Date: Dec 2004
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
 
Old January 10th, 2005, 05:05 PM
Authorized User
 
Join Date: Dec 2004
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





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





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