Bill Patterson on Tue, 2 Sep 2003 11:27:05 -0400

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Tabs

You wrote:
>Date: Tue, 02 Sep 2003 00:03:04 -0400
>From: Paul <>
>Subject: [PLUG] Tabs
>Question for Perl and/or PHP people: How could I get PHP to honor the \t 
>in a text output from a Perl script?
>In PHP I'm using shell_exec() to call the Perl script and nl2br() to 
>convert \n to <br />.  The \t is totally ignored.  I don't care if the 
>final output is text or HTML.  Help?

Here is an example:

cat >
print "This is a tab\tthat is embedded\n";

cat >test.php
echo "buffer = $buffer\n";
foreach($tab_delim as $key=>$value) {
  echo "line $key = $value\n";

then enter:
perl | php test.php

and you will see:
buffer = This is a tab  that is embedded

line 0 = This is a tab
line 1 = that is embedded

Philadelphia Linux Users Group        --
Announcements -
General Discussion  --