Re: Breaking Up a String

From: Date: Sun, 17 Dec 2000 21:24:02 +0000
Subject: Re: Breaking Up a String
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-30764@lists.php.net to get a copy of this message
Sure: <? $line = '"Joe Schmoe","10/00","2345","California"'; $fields = explode(',',$line); for($i = 0 ; $i < sizeof($fields) ; ++$i) { $new_fields[$i] = str_replace('"','',$fields[$i]; } $name = $new_fields[0]; $date = $new_fields[1]; // etc, etc. ?> --Joe On Sun, Dec 17, 2000 at 02:26:14PM -0700, Jason Beebe wrote: > Hey, > > Anyone have an efficient way of doing this. > Say I have a string deliminated and seperated by quotes and comas like this: > "Joe Shmoe","10/00","2342","California" etc... > there's about 8 fields of information. > How could I seperate each one into a seperate variable. I was thinking that putting the > seperated data into an array may work and sort it from there. > $name = $separray[0]; > $date = $separray[1]; > > It always returns the fields in the same order, so that is not a problem. How would I seperate > this information to begin with. Then, what would be the best method of assigning the seperated data > into it's own unique variable? Thanks. --- Joe Stump PHP Programmer www.Care2.com

« previous php.general (#30764) next »