Bill Patterson on Tue, 2 Sep 2003 11:27:05 -0400 |
You wrote: >Date: Tue, 02 Sep 2003 00:03:04 -0400 >From: Paul <emailme@dpagin.net> >To: plug@lists.phillylinux.org >Subject: [PLUG] Tabs >Reply-To: plug@lists.phillylinux.org > >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 >test.pl #!/usr/bin/perl print "This is a tab\tthat is embedded\n"; cat >test.php <?PHP $std_in=fopen("php://stdin","r"); $buffer=fread($std_in,32767); $tab_delim=split("\t",$buffer); echo "buffer = $buffer\n"; foreach($tab_delim as $key=>$value) { echo "line $key = $value\n"; } ?> then enter: perl test.pl | 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 Bill _________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce General Discussion -- http://lists.netisland.net/mailman/listinfo/plug
|
|