Re: fscanf syntax
| From: | Brian Clark | Date: | Sat, 31 Mar 2001 02:11:28 +0000 |
| Subject: | Re: fscanf syntax | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-46415@lists.php.net to get a copy of this message | ||
Hi Patrick,
@ 9:04:59 PM on 3/30/2001, Patrick Brown wrote:
...
> hostname|protocol|number|severity|description
> Each record is on it's own line and have the fields delimited by the pipe
> character |. The file may have thousands of records and I would like to
> bring them into a database for reporting.
...
> What function should I use and what would the syntax be?
Try explode().
<?php
/* this could be read in from a file instead, of course. */
$line = 'hostname|protocol|number|severity|description';
$parts = explode('|',$line); /* like perl's split. */
while(list(,$part) = each($parts))
{
/* do something with each $part */
...
}
?>
-Brian
--
PGP is spoken here: 0xE4D0C7C8
Please do not carbon copy me on list replies.