firstly, I want to break down for example, a text file, so it reads word by word in to an array. I then want to add this array to an sql database.
I am using explode to use this so this makes the arrray, but when I insert it to the database it comes out just as 'array array array' and not the contents of the file.
if i echo the explode array it comes out with the contents in the browser.
Is there a way to put the results from the explode into a new array that can be inserted into the database.BMW GT1 Diagnsotic Tool
this is my code
function opening($file)
{
$pattern = "(\.txt$)| (\.php$)";
if(eregi($pattern, $file)){
$file_handle=fopen($file, "rb");
while (!feof($file_handle)){
$line_of_text = fgets($file_handle);
$parts = explode(" ", $line_of_text);
printing($parts);
}
fclose($file_handle);}
else {
echo "Cant open that file type <p>"; }
}
function newarray($parts){
$data = array();
for($i = 0; $i < count($parts); ++$i)
$data[] = $parts;
}
I am trying to make a function to put this wanted data into a new array, but not sure how. obviously need a loop
Any help would be great. cheers
I am using explode to use this so this makes the arrray, but when I insert it to the database it comes out just as 'array array array' and not the contents of the file.
if i echo the explode array it comes out with the contents in the browser.
Is there a way to put the results from the explode into a new array that can be inserted into the database.BMW GT1 Diagnsotic Tool
this is my code
function opening($file)
{
$pattern = "(\.txt$)| (\.php$)";
if(eregi($pattern, $file)){
$file_handle=fopen($file, "rb");
while (!feof($file_handle)){
$line_of_text = fgets($file_handle);
$parts = explode(" ", $line_of_text);
printing($parts);
}
fclose($file_handle);}
else {
echo "Cant open that file type <p>"; }
}
function newarray($parts){
$data = array();
for($i = 0; $i < count($parts); ++$i)
$data[] = $parts;
}
I am trying to make a function to put this wanted data into a new array, but not sure how. obviously need a loop
Any help would be great. cheers
Comment