Re: split on tabs

From: Date: Wed, 05 Jul 2000 18:47:16 +0000
Subject: Re: split on tabs
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5031@lists.php.net to get a copy of this message
Your suggestion is the first thing I tried. Here is what I'm running: Linux SuSe 6.4, apache 1.3.12, PHP 4.0.1pl2. I'm stumped. But since you show the correct syntax, that tells me I need to look elsewhere for the problem. If you have suggestion on where else to look for problem other than PHP, I'd appreciate it. Thanks. I'm reading in records from a file, but to test thinking the file is not in the format I expect, I created a fixed string to test with called $record. Here are the commands I tried: $record = "field1\tfield2\tfield3" ; $new = split("\t",$record) ; $new = split("[[:tab:]]",$record) ; $new = split("\T",$record) ; // tried single quotes just in case it made difference $new = split('\t',$record) ; $new = split('[[:tab:]]',$record) ; $new = split('\T',$record) ; Jose de Leon System Administrator InVision Telecommunications (209) 549-8800 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FAST Internet Access and no bull. InVision DSL, www.invisiondsl.com ----- Original Message ----- From: Rasmus Lerdorf <rasmus@php.net> To: Jose de Leon <jadiel@thevision.net> Cc: <php-general@lists.php.net> Sent: Wednesday, July 05, 2000 11:24 AM Subject: Re: [PHP] split on tabs $new = split("\t",$old); However, if your delimiter is a simple single character like this, use explode() instead: $new = explode("\t",$old); (what in the world did you try? This seems so obvious to me) -Rasmus On Wed, 5 Jul 2000, Jose de Leon wrote: > Okay, I've tried at least 6 different incantations of split() in order to > split on a tab delimited record. It just doesn't work as expected. > Additionally, there is no mention in the regex.7 manual on how to split on > tabs! I supposed I could use the ctype 'space', but that won't work since > some of the fields have spaces in them. I only want to split on tabs. > > Suggestion on correct syntax please? > > > Thanks, > > Jose de Leon > System Administrator > InVision Telecommunications > (209) 549-8800 > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > FAST Internet Access and no bull. > InVision DSL, www.invisiondsl.com > > > >

« previous php.general (#5031) next »