mercredi 23 mars 2016

Multiple strpos to create an insert

I am trying to search through a large text file and pick out the useful information and then insert it in to my database.

$handle = fopen($data, "r");
    if ($handle) 
    {
        while (($line = fgets($handle)) !== false) 
        {

            if (strpos($line, 'user')===0) 
            {
                $user = $line;       
            }

            if (strpos($line, 'email')===0) 
            {
                $email = $line;
            }

            DB::table('id_users')->insert(
                ['User' => $user],
                ['Email' => $email]);

        }
    }

Any help/advice is appreciated.

Aucun commentaire:

Enregistrer un commentaire