Re: [PHP] array looping

2003-08-14 Thread Micah Montoy
When I tried the

$file_contents = explode(",",$file_contents);

I get the error:

Notice: Array to string conversion in
c:\inetpub\wwwroot\webpage10\example\search\dsp_search.php on line 111

When I do

echo ($file_contents);

the output is Array.  When I do

echo ($file_contents[0]);

I get all the content of file, so everything is in array 0.  I need to
somehow break up the array by the comma.


"Chris W. Parker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Micah Montoy 
on Tuesday, August 12, 2003 3:35 PM said:

> I have this text file that I pull in and I need to transverse through
> the file and assign each value in the file into an array.

Hehe... you mean traverse.

Transverse:
1 : acting, lying, or being across : set crosswise
2 : made at right angles to the anterior-posterior axis of the body 

> The text in the file is separated by a comma.

This is called "delimit".

You say the file looks a bit like "and,not,it,i,a,c,nope". Are there any
new line characters (\n) in the file or is it just one really long line?
If there ARE newlines in the file does it look like this:

a,b,c,d,e,f,g,
h,i,j,k,l,m,n,

or this:

a,b,c,d,e,f,g
h,i,j,k,l,m,n

??

(notice there is no comma at the end of the line in the second example)


Chris.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] array looping

2003-08-14 Thread Micah Montoy
You where right.  I realized this a bit after I posted.  I got it going once
I realized what I had forgotten.

thanks everyone for your input


"Liam Gibbs" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > I get all the content of file, so everything is in array 0.  I need to
> > somehow break up the array by the comma.
>
> Wouldn't it be $file_contents = explode(",", $file_contents[0]);
>
> as in you've forgotten the array element?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] array looping

2003-08-14 Thread Micah Montoy
I have this text file that I pull in and I need to transverse through the
file and assign each value in the file into an array.  The text in the file
is separated by a comma.  I was thinking of something along the lines of
explode but its only for strings and I couldn't get it to work with arrays.
Right now everything in the file is counted as an array.  For example, I
have the word "and" in the file.  Each letter is an array but I want it so
that it pulls in the entire word "and" and not each letter.

The file looks a bit like this:

and,not,it,i,a,c,nope

My function looks like this:

function i_strip_words($line) {
$nline = "";
$file_contents = @file($GLOBALS['exclude_words']);

if ($file_contents) {

 foreach ($file_contents as $nword) {
  $nword = trim($nword);
  $nword = str_replace(",", "\n", $nword);

foreach ($line as $s_string) {
   if ($nword == $s_string) {
$line = str_replace("$nword", "", $s_string);
$line = $nline.line;
   }
  }
   }
}

return $line;
}

Whats a really simple way to do this or is there?  I saw some examples but
they looked really ugly and confusing.

thanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] array looping

2003-08-14 Thread Micah Montoy
No, one long file.  I can separate it out any way though.  Any ideas?


"Chris W. Parker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Micah Montoy 
on Tuesday, August 12, 2003 3:35 PM said:

> I have this text file that I pull in and I need to transverse through
> the file and assign each value in the file into an array.

Hehe... you mean traverse.

Transverse:
1 : acting, lying, or being across : set crosswise
2 : made at right angles to the anterior-posterior axis of the body 

> The text in the file is separated by a comma.

This is called "delimit".

You say the file looks a bit like "and,not,it,i,a,c,nope". Are there any
new line characters (\n) in the file or is it just one really long line?
If there ARE newlines in the file does it look like this:

a,b,c,d,e,f,g,
h,i,j,k,l,m,n,

or this:

a,b,c,d,e,f,g
h,i,j,k,l,m,n

??

(notice there is no comma at the end of the line in the second example)


Chris.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] array looping

2003-08-14 Thread Liam Gibbs
> I get all the content of file, so everything is in array 0.  I need to
> somehow break up the array by the comma.

Wouldn't it be $file_contents = explode(",", $file_contents[0]);

as in you've forgotten the array element?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] array looping

2003-08-14 Thread Chris W. Parker
Micah Montoy 
on Tuesday, August 12, 2003 3:35 PM said:

> I have this text file that I pull in and I need to transverse through
> the file and assign each value in the file into an array.

Hehe... you mean traverse.

Transverse:
1 : acting, lying, or being across : set crosswise
2 : made at right angles to the anterior-posterior axis of the body 

> The text in the file is separated by a comma.

This is called "delimit".

You say the file looks a bit like "and,not,it,i,a,c,nope". Are there any
new line characters (\n) in the file or is it just one really long line?
If there ARE newlines in the file does it look like this:

a,b,c,d,e,f,g,
h,i,j,k,l,m,n,

or this:

a,b,c,d,e,f,g
h,i,j,k,l,m,n

??

(notice there is no comma at the end of the line in the second example)


Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php