
japhy
Enthusiast
Nov 14, 2000, 9:31 AM
Views: 241
|
Re: Parsing Delimited String
|
|
|
If you read the documentation for split(), you'll see that you can tell it to split it into a specific number of parts: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> $str = "john jacob jingleheimer schmidt"; ($first,$mid1,$mid2,$last) = split ' ', $str; print "$first, $mid1, $mid2, $last\n"; # john, jacob, jingleheimer, schmidt ($first,$rest) = split ' ', $str, 2; print "$first, $rest\n"; # john, jacob jingleheimer schmidt </pre><HR></BLOCKQUOTE> ------------------ Jeff "japhy" Pinyan -- accomplished author, consultant, hacker, and teacher
|