Updater(); } private function Updater() { $lines = array(); //Create the file handler $data = Storage::get('public/moon_data.txt'); //Split the string into separate arrays based on the line $data = preg_split("/\n/", $data); //For each array of data, let's separate the data into more arrays built in arrays for($i = 0; $i < sizeof($data); $i++) { //Strip the beginning [ from the line $temp = str_replace('[', '', $data[$i]); //Strip the ending ] from the line $temp = str_replace(']', '', $temp); //Remove the spacees from the line $temp = str_replace(' ', '', $temp); //Remove the quotes from the line $temp = str_replace("'", '', $temp); //Split up the line into separate arrays after each comma $lines[$i] = preg_split("/,/", $temp); } /** * The output within the lines array * 0 => System * 1 => Planet * 2 => Moon * 3 => FirstOre * 4 => FirstQuan * 5 => SecondOre * 6 => SecondQuan * 7 => ThirdOre * 8 => ThirdQuan * 9 => FourthOre * 10 => FourthQuan */ foreach($lines as $line) { AllianceMoon::where([ 'System' => $line[0], 'Planet' => $line[1], 'Moon' => $line[2], ])->update([ 'FirstOre' => $line[3], 'FirstQuantity' => $line[4], 'SecondOre' => $line[5], 'SecondQuantity' => $line[6], 'ThirdOre' => $line[7], 'ThirdQuantity' => $line[8], 'FourthOre' => $line[9], 'FourthQuantity' => $line[10], ]); } } }