php-general | 2001032
Date: 03/30/01
- Next message: Chris Fry: "Re: [PHP] fscanf syntax"
- Previous message: Jack Dempsey: "Re: [PHP] No-refresh"
- In reply to: Patrick Brown: "[PHP] fscanf syntax"
- Next in thread: Chris Fry: "Re: [PHP] fscanf syntax"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Chris Fry: "Re: [PHP] fscanf syntax"
- Previous message: Jack Dempsey: "Re: [PHP] No-refresh"
- In reply to: Patrick Brown: "[PHP] fscanf syntax"
- Next in thread: Chris Fry: "Re: [PHP] fscanf syntax"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

