First of all, you can't use explode like that, you need to set a array variable to the exploded results. Something like this:
$array1=explode('|',$line);
Using Laser's file() reference, we could do something like this:
//First, create the beginning of the insert statement:
$insert="insert into `sometable`
(Transaction_Type,
MLSNumber,
ListOfficeId,
Address1,
Address2,
City,
Company,
EmailAddress,
PhoneMain,
State,
WebPage,
Zip5,
ListAgentId,
Agent_Email) values ";
$lines = file('http://www.example.com/'); // Get a file into an array.
$count=count($lines); // count how many lines in the file
for ($i=1,$i<=($count-1);$i++) // for each line in the file, except the last one...
{
$line=array_pop($lines); //take a line from the array of lines
$array_of_values=explode('|',$line); //explode it into values
$insert .= "("; // append opening parenthesis
$count2=count(array_of_values); // get the number of values to insert
for ($j=0;$j<=($count2-2);$j++) // Process each value except the last
{
$insert .= "\"$array_of_values[$j]\","; //append each value on the end
}
$insert .= "\"".$array_of_values[($count2-1)]."\"),"; // add last value on the end
}
$line=array_pop($lines); // getting the last line
$array_of_values=explode('|',$line); // last batch of values
$count2=count($array_of_values);
$insert .= "(";
for ($j=0;$j,<=($count2-2);$j++)
{
$insert .= "\"".$array_of_values[$j]."\",";
}
$insert .= "\"".$array_of_values[($count2-1)]."\")";
echo "Your insert statement is $insert";