Hi, Guys&Girls sorry if this is in the wrong place but it is the only place it would let me post anything I am new to the site and need help converting a txt file the file has a max of 2000 line and looks like this 1006:93:89:16,6473:94:21:33 1009:47:13:95,624:15:78:4 1019:53:77:46,4547:29:42:78 1022:39:26:64,39:52:59:99 1024:48:28:52,7087:29:70:75 i need to convert the above so i can insert it directly in to an sql database it need to look like this exactly not sure what is the best way to do it either somekind of script to convert the file or a script sql script new to all this but getting there at the moment i have to do it manually which just takes me hours thanks in advance for your help ( , 1, '1006', '6473', '93-89-16', '94-21-33', '', 'Lee', 1283682460), if anybody can make a program to do this i would be willing to pay for it thanks Lee
<?php $lines = file("text.txt"); foreach($lines as $item) { $item = str_replace(",",":",$item); $item = explode(":", rtrim($item)); echo "<br />"; echo "( , 1, '$item[0]', '$item[4]', '$item[1]-$item[2]-$item[3]', '$item[5]-$item[6]-$item[7]', '', 'Lee', 1283682460),"; } ?> PHP: ( , 1, '1006', '6473', '93-89-16', '94-21-33', '', 'Lee', 1283682460), ( , 1, '1009', '624', '47-13-95', '15-78-4', '', 'Lee', 1283682460), ( , 1, '1019', '4547', '53-77-46', '29-42-78', '', 'Lee', 1283682460), ( , 1, '1022', '39', '39-26-64', '52-59-99', '', 'Lee', 1283682460), ( , 1, '1024', '7087', '48-28-52', '29-70-75', '', 'Lee', 1283682460), Code (markup):