PDA

View Full Version : How do I do this in PHP?


Shan
04-08-2004, 02:34 PM
I am trying to parse a line in a document.

The line is always 64 characters long.
Always divided into 8 calumbs of data with trailing spaces to fill the remaining 8 characters.

I need to parse the line and store the 8 pieces of information into an database.

I know I can create my own function with seeks, rtrims, etc.

My question is this: is there a built in function in PHP (similar to the SSCANF() function) that will scan through a line and divide it into chunks based on fixed character lengths?

Shan

filburt1
04-08-2004, 03:02 PM
You can do this:

$substrings = explode(" ", $string);
foreach ($substrings as $key => $value)
{
$substrings[$key] = trim($value);
}