[PHP] array2string

2005-09-10 Thread David Christensen
Pardon my ignorance and lack of ability to form the right search for
google, but I'm trying to figure out if there's a simple function in PHP
to convert array values to a string with a separator for each value.

eg.

$arr = array(1, 5, 2);
$str = some_funct($arr, ',');

print $str;  # 1,5,2



Thanks for your help,

David Christensen

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



[PHP] Regular expression help

2005-08-02 Thread David Christensen
I just plain suck at regex, so I was hoping to get some hints from you
regex experts out there.  I'm sure it's been done a thousand times, but
I can't seem to find what I'm looking for with a simple google search:

$phone could be 1234567890 OR
$phone could be 123-456-7890 OR
$phone could be (123) 456 7890 OR
$phone could have other unexpected characters in it, even control
characters.

So what I'm desiring to do is run some type of regex on $phone and only
return the integers and assign the cleaned string back to $phone.  I
thought I knew how to do this, but it's not working.

Thanks for your guidance.

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



Re: [PHP] Dropdown Building Function

2005-07-29 Thread David Christensen
On Fri, 2005-07-29 at 15:58 -0400, Jack Jackson wrote:
 Hi, can anyone even point me in a *direction*? I suppose this is the 
 most complex thing I've ever tried to do and I have been at it for tens 
 of hours and am still completely baffled.
 
 
 Jack Jackson wrote:
  Hi,
  because that last topic on multipage forms was so exciting, I decided to 
  database the questions as well. I wonder if anyone can help me with a 
  function to pull rows into dropdown boxes.
  
  It's a 1:n relationship between questions and answers, and I have a 
  table of questions
  
  q_id
  q_name
  q_text
  q_style //dropdown, radio, checkboxes
  q_cat //question category
  
  and a table full of answers
  
  a_id
  q_id
  a_answer
  
  
  When I do
  
  $fields = 'SELECT *';
  $from = 'FROM questions,answers';
  $sort = ORDER BY questions.q_cat;
  $where = WHERE answers.q_id=questions.q_id;
  
  // construct the sql query:
  $sql = $fields $from $where $sort;
  
  // Run SQL query 1
  if (!($result = mysql_query($sql))) {
  echo Could not connect to the database ($sql) . mysql_error();
  }
  
  while ($row = mysql_fetch_assoc($result)) {
  
  
  I need to loop through the results and make a dropdown list from them, 
  taking the question name as the select name, and then making each answer 
  id and answer text the makings of an option ros.
  
  Based on a problem a while ago which was similar but different, someone 
  here actually made me a function *similar* to what I need to do now, 
  This one acts different and I just cannot adapt the old one, because I 
  still get confused at this level.
  
  I think it wants to be something like (and note that part of the return 
  is the code to react to error checking results):
  
  $dropdown[] = 'option ?php if (' . $q_name . ' == ' . $a_id . ') 
  echo selected ; ? value=\'' . $a_id . '\'' . $a_answer . '/option';
  
  etc for all $a_answer(s)...
  and then
  
  return '?php if (sizeof($message[\'' . $q_name . '\'])){ echo div 
  class='error'; } ?
  div class=\'row\'
  select class=\'answer\' name=\'' . $q_name . '\'
  option value=\'\'Select from this list/option'
   join('',$dropdown)
   . '/select/div'
   . '?php if (sizeof($message[\''. $q_name '\'])){ echo 
  /div!--/error--; } ?';
  
  
  Can anyone point me at the right direction?
  
  Thanks!!
  
  JJ
  
 

JJ,

I like to TBS (TinyButStrong) for all of my PHP-HTML needs.  There are
build in functions to handle output from database to a list like this as
well as wide depth of other great features for auto-generating specific
HTML.

http://www.tinybutstrong.com

Dave

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



Re: [PHP] control-M

2005-05-05 Thread David Christensen
Actually, I forgot to also mention that the browser is changing the
control-M (^M) from the query when it sets the default value for the
textarea to br /.  I guess that is the HTML representation of the
^M.

I'm currently using:

$_POST[$field] = str_replace(\r\n, \n, $_POST[$field]);
$_POST[$field] = strip_tags($_POST[$field], 'br /');

in a foreach loop for all the $_POST vars, but it's still not removing
it.

Dave

On Thu, 2005-05-05 at 10:12 +0200, Marek Kilimajer wrote:
 David Christensen wrote:
  I know I'm missing something, but I can't seem to find it or figure it
  out.  I've done the google search, and I've done a quick scan of the
  list archives, but I can't seem to find the right way to remove
  control-M from a form submission page with textarea fields.
  
  I have a series of textarea fields that can/and do contain the dreaded
  ^M characters.  For the life of me, I can't figure out how to remove
  them before I save them to the database, and how to remove the ones that
  are all ready stored there when I query them back to the browser from a
  web page.  Also, if I do remove them, how do I make sure I format the
  text correctly when I push it back to the browser as the default values
  of these fields?
  
  Point me to the elixir of knowledge and let me bath in the fortitude of
  a master regex expression to rid me once and for all of the dreaded
  ^M!!!
  
  Thank you, and good night!
 
 ... = str_replace(\r\n, \n, ...);
 
 But I don't see how this would infuence the default values of form 
 inputs, plain htmlspecialchars() should be enough.
 

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



Re: [PHP] control-M

2005-05-05 Thread David Christensen
These aren't text files, there form fields from a browser and fields
from query.  I don't think dos2unix will be of much help with this.

Dave


On Thu, 2005-05-05 at 09:07 +0300, Petar Nedyalkov wrote:
 On Thursday 05 May 2005 06:13, David Christensen wrote:
  I know I'm missing something, but I can't seem to find it or figure it
  out.  I've done the google search, and I've done a quick scan of the
  list archives, but I can't seem to find the right way to remove
  control-M from a form submission page with textarea fields.
 
  I have a series of textarea fields that can/and do contain the dreaded
  ^M characters.  For the life of me, I can't figure out how to remove
  them before I save them to the database, and how to remove the ones that
  are all ready stored there when I query them back to the browser from a
  web page.  Also, if I do remove them, how do I make sure I format the
  text correctly when I push it back to the browser as the default values
  of these fields?
 
 There's a tool called dos2unix - use it.
 
 
  Point me to the elixir of knowledge and let me bath in the fortitude of
  a master regex expression to rid me once and for all of the dreaded
  ^M!!!
 
  Thank you, and good night!
 
  That's why I won't do 2 shows!  I won't do it!
 

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



Re: [PHP] control-M

2005-05-05 Thread David Christensen
Joe, not sure you str_replace will work.  I think I need a way to
represent the ^M with an ASCII code.  The ^M character is a single
character.  If you type ^M that is 2 characters, caret + M.  They are
not equal ASCII-wise.

Dave


On Thu, 2005-05-05 at 03:11 -0400, Joe Wollard wrote:
 David,
 
 Well, I've never seen this issue on a form submission before, but I
 have seen it (and other oddities) when editing text files in vi that
 we created on M$.  You might try something simple first such as:
 ?php
 $text = str_replace(^M\n\r, \n\r, $_POST['textarea_name']);
 ?
 
 I haven't tested that but I'd give that a shot. If you're always
 getting the ^M before a line break this should work but I haven't
 tested it to be sure. Even if you have to modify it I would still use
 str_replace instead of a regular expression since you'll know exactly
 what/ where the string is that you want to get rid of.
 
 If ^M isn't actually being detected as a literal string you would just
 replace it with the ASCii value inside of the chr() function.I
 think ;-)
 
 Cheers!
 -Joe
 www.joewollard.com
 
 
 David Christensen wrote: 
  I know I'm missing something, but I can't seem to find it or figure it
  out.  I've done the google search, and I've done a quick scan of the
  list archives, but I can't seem to find the right way to remove
  control-M from a form submission page with textarea fields.
  
  I have a series of textarea fields that can/and do contain the dreaded
  ^M characters.  For the life of me, I can't figure out how to remove
  them before I save them to the database, and how to remove the ones that
  are all ready stored there when I query them back to the browser from a
  web page.  Also, if I do remove them, how do I make sure I format the
  text correctly when I push it back to the browser as the default values
  of these fields?
  
  Point me to the elixir of knowledge and let me bath in the fortitude of
  a master regex expression to rid me once and for all of the dreaded
  ^M!!!
  
  Thank you, and good night!
  
  That's why I won't do 2 shows!  I won't do it!
  


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



Re: [PHP] control-M

2005-05-05 Thread David Christensen
I am?  That news to me???  I just did a 'grep nl2br form.php' and I
don't any output with nl2br.  I'm not sure this is what's going on.

I did see that function in the Strings section of the manual, but it
didn't do anything for me.

Thanks for your help,

Dave


On Thu, 2005-05-05 at 16:11 +0200, Marek Kilimajer wrote:
 David Christensen wrote:
  Actually, I forgot to also mention that the browser is changing the
  control-M (^M) from the query when it sets the default value for the
  textarea to br /.  I guess that is the HTML representation of the
  ^M.
 
 you are using nl2br() on the input, that funcion adds 'br /' before 
 all newline characters.
 
  
  I'm currently using:
  
  $_POST[$field] = str_replace(\r\n, \n, $_POST[$field]);
  $_POST[$field] = strip_tags($_POST[$field], 'br /');
  
  in a foreach loop for all the $_POST vars, but it's still not removing
  it.
  
  Dave
  
  On Thu, 2005-05-05 at 10:12 +0200, Marek Kilimajer wrote:
  
 David Christensen wrote:
 
 I know I'm missing something, but I can't seem to find it or figure it
 out.  I've done the google search, and I've done a quick scan of the
 list archives, but I can't seem to find the right way to remove
 control-M from a form submission page with textarea fields.
 
 I have a series of textarea fields that can/and do contain the dreaded
 ^M characters.  For the life of me, I can't figure out how to remove
 them before I save them to the database, and how to remove the ones that
 are all ready stored there when I query them back to the browser from a
 web page.  Also, if I do remove them, how do I make sure I format the
 text correctly when I push it back to the browser as the default values
 of these fields?
 
 Point me to the elixir of knowledge and let me bath in the fortitude of
 a master regex expression to rid me once and for all of the dreaded
 ^M!!!
 
 Thank you, and good night!
 
 ... = str_replace(\r\n, \n, ...);
 
 But I don't see how this would infuence the default values of form 
 inputs, plain htmlspecialchars() should be enough.
 
  
  
 

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



Re: [PHP] control-M

2005-05-05 Thread David Christensen
Oh, you just clued me in...  I wonder if [EMAIL PROTECTED] might be
able to shed some like on this.  I'm using TBS as my template engine for
this site.  And yes, it does use nl2br in the meth_Html_Conv function.
I'll probably need to add the htmlconv=no option to all of the
textarea fields.  I think I can be pretty sure the user won't need to
enter any HTML into this fields.

Thanks Marek!  You pointed me in the right direction!


On Thu, 2005-05-05 at 20:08 +0200, Marek Kilimajer wrote:
 David Christensen wrote:
  I am?  That news to me???  I just did a 'grep nl2br form.php' and I
  don't any output with nl2br.  I'm not sure this is what's going on.
  
  I did see that function in the Strings section of the manual, but it
  didn't do anything for me.
  
 
 Well, php isn't making it up, it has to be somewhere. Or are you using 
 any htmlarea kind of input? We need to see your form.php to help you.
 
  On Thu, 2005-05-05 at 16:11 +0200, Marek Kilimajer wrote:
  
 David Christensen wrote:
 
 Actually, I forgot to also mention that the browser is changing the
 control-M (^M) from the query when it sets the default value for the
 textarea to br /.  I guess that is the HTML representation of the
 ^M.
 
 you are using nl2br() on the input, that funcion adds 'br /' before 
 all newline characters.
 
 
 

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



[PHP] control-M

2005-05-04 Thread David Christensen
I know I'm missing something, but I can't seem to find it or figure it
out.  I've done the google search, and I've done a quick scan of the
list archives, but I can't seem to find the right way to remove
control-M from a form submission page with textarea fields.

I have a series of textarea fields that can/and do contain the dreaded
^M characters.  For the life of me, I can't figure out how to remove
them before I save them to the database, and how to remove the ones that
are all ready stored there when I query them back to the browser from a
web page.  Also, if I do remove them, how do I make sure I format the
text correctly when I push it back to the browser as the default values
of these fields?

Point me to the elixir of knowledge and let me bath in the fortitude of
a master regex expression to rid me once and for all of the dreaded
^M!!!

Thank you, and good night!

That's why I won't do 2 shows!  I won't do it!

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



[PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
I'm trying to figure out the best way to handle a SELECT from multiple
tables where a single ID in tableA relates to multiple ID's in tableB:

SELECT tableA.ID, tableB.data FROM tableA, tableB WHERE tableA.ID=3 AND
tableA.ID=tableB.tableAID

What I'm trying to product is an array output similar to:

| ID | data |
| 3  | data1, data2, data3 |

if the table data is represented by this:

tableA
| ID | something  |
| 1  | something1 |
| 2  | something2 |
| 3  | something3 |

tableB
| ID | tableAID | data  |
| 1  | 3| data1 |
| 2  | 3| data2 |
| 3  | 3| data2 |

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



RE: [PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
Your example doesn't produce the desired the results!

The reason I posted to the PHP list was I thought I would have to apply
some ARRAY functions to produce the output I'm looking for.  Your
example did nothing more than mine produced.


On Thu, 2005-03-24 at 12:48 -0600, Jay Blanchard wrote:
 [snip]
 I'm trying to figure out the best way to handle a SELECT from multiple
 tables where a single ID in tableA relates to multiple ID's in tableB:
 
 SELECT tableA.ID, tableB.data FROM tableA, tableB WHERE tableA.ID=3 AND
 tableA.ID=tableB.tableAID
 
 What I'm trying to product is an array output similar to:
 
 | ID | data |
 | 3  | data1, data2, data3 |
 [/snip]
 
 SELECT a.foo, b.foobar 
 FROM tableA a LEFT OUTER JOIN tableB b
 ON(a.id = b.id)
 
 SELECT p.users 
 FROM php.list p LEFT OUTER JOIN mysql.list m
 ON (p.phpuserid = m.mysqluserid)
 GROUP BY p.users
 HAVING clue  0;

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



RE: [PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
YES!

All it does differently is truncate the output to one row per entry in
tableA.


On Thu, 2005-03-24 at 11:35 -0800, Chris W. Parker wrote:
 David Christensen mailto:[EMAIL PROTECTED]
 on Thursday, March 24, 2005 11:24 AM said:
 
  Your example doesn't produce the desired the results!
  
  The reason I posted to the PHP list was I thought I would have to
  apply some ARRAY functions to produce the output I'm looking for. 
  Your example did nothing more than mine produced.
 
 Yeah but did you try the second query?
 

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



RE: [PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
NO Spanky!

I figured it was implied that I was looking for a PHP solution since I
posted to a PHP list!

I also didn't ask for help with HTML output.  I was asking for help with
PHP output!

Let me try to explain it a little better...

I need to produce an array of results from two tables.  The first table
contains the unique records, let's call it 'customers'.  The second
table, let's call it 'orders', contains records that are referenced to
'customers' via a 'customerID' field that correlates to the
'ID' (primary_key) field in 'customers'.

What I'm after is a multidimensional array that contains a list of
information which includes 'ID' from customers, 'name' from customers
and 'order_info' from 'orders' which is collapsed into a field of the
new multidimensional array similar to the following:

OUTPUT equivalent to
$array[0] = array('ID' = 1, 'name' = 'joe', 'order_info' = 'part1,
part2, part3');
$array[1] = array('ID' = 2, 'name' = 'jim', 'order_info' = 'part1,
part5, part9');
$array[2] = array('ID' = 3, 'name' = 'moe', 'order_info' = 'part2,
part3, part7');

'customers'
| ID | name |
| 1  | joe  |
| 2  | jim  |
| 3  | moe  |

'orders'
| ID | customerID | part  |
| 1  | 1  | part1 |
| 2  | 1  | part2 |
| 3  | 1  | part3 |
| 4  | 2  | part1 |
| 5  | 2  | part5 |
| 6  | 2  | part9 |
| 7  | 3  | part2 |
| 8  | 3  | part3 |
| 9  | 3  | part7 |

Hope this clears it up a bit.


On Thu, 2005-03-24 at 13:46 -0600, Jay Blanchard wrote:
 [snip]
 Your example doesn't produce the desired the results!
 
 The reason I posted to the PHP list was I thought I would have to apply
 some ARRAY functions to produce the output I'm looking for.  Your
 example did nothing more than mine produced.
 [/snip]
 
 
 It produces EXACTLY what you asked for in the OP. You didn't ask how do
 I make this look pretty with PHP?
 
 In order to do that, do this...
 
 echo tr;
 echo td.$id./td;
 while($id){
   echo td.$data./td
 }
 echo /tr;
 
 Is that better Sparky?

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



RE: [PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
My apologies!  I thought I was giving what I was getting as far as the
angle of my post.

I still don't think everyone is understanding what I'm after here
though.  I know how to use the mysql functions in PHP.  That is not my
problem.  I'm trying to avoid having to make multiple queries to the db
in order to combine two array results.

I understand this is a one-to-many relationship, but I'm not really
after the default output that produces.  I want the 'many' to be a
single element in the customer line array (referencing my last post.)

So if the result is that customer '1' has ordered 3 items, and each item
is a separate line in the 'orders' table that get returned from the
query, I want an array of:

$array[0] = ('ID' = 1, 'name' = 'joe', 'items' = 'part1, part2,
part3');

I don't know how to say it any plainer than that.

The original post would have produced the following:

1, 'joe', 'part1'
1, 'joe', 'part2'
1, 'joe', 'part3'

but what I'd like to get is:
1, 'joe', 'part1, part2, part3'

Thanks for your help.  I think I may have to redesign this thing to make
this easier or I maybe I just don't have the vocabulary to ask the
question correctly.

On Thu, 2005-03-24 at 12:17 -0800, Chris W. Parker wrote:
 David Christensen mailto:[EMAIL PROTECTED]
 on Thursday, March 24, 2005 12:07 PM said:
 
  NO Spanky!
 
  I figured it was implied that I was looking for a PHP solution since I
  posted to a PHP list!
  
  I also didn't ask for help with HTML output.  I was asking for help
  with PHP output!
 
 Yikes.
 
  Let me try to explain it a little better...
  
  I need to produce an array of results from two tables.  The first
  table contains the unique records, let's call it 'customers'.  The
  second table, let's call it 'orders', contains records that are
  referenced to 'customers' via a 'customerID' field that correlates to
  the 'ID' (primary_key) field in 'customers'.
 
 Yes, this is called a one-to-many relationship.
 
  What I'm after is a multidimensional array that contains a list of
  information which includes 'ID' from customers, 'name' from customers
  and 'order_info' from 'orders' which is collapsed into a field of the
  new multidimensional array similar to the following:
 
  OUTPUT equivalent to
  $array[0] = array('ID' = 1, 'name' = 'joe', 'order_info' = 'part1,
  part2, part3');
  $array[1] = array('ID' = 2, 'name' = 'jim', 'order_info' = 'part1,
  part5, part9');
  $array[2] = array('ID' = 3, 'name' = 'moe', 'order_info' = 'part2,
  part3, part7');
 
 Did you read the manual? The PHP functions for MySQL already do this
 automatically! In fact they organize the output even better!
 
 Start here: http://us4.php.net/mysql. (HINT: mysql_fetch_array().)
 
 Next time don't be hostile and post a more clearly worded question[1].
 You'll save everyone a lot of time.
 
 
 
 Chris.
 
 [1] Read here: www.catb.org/~esr/faqs/smart-questions.html
 

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



RE: [PHP] collapse SELECT from multiple tables

2005-03-24 Thread David Christensen
Thanks, I just use my original SQL and setup a foreach loop to compare
the 'ID' to see whether or not a record was returned with multiple row
results.

I was just hoping someone had all ready figured out some kool, neato,
voodoo-magic way to handle a one-to-many result like this.


On Thu, 2005-03-24 at 13:02 -0800, Chris W. Parker wrote:
 David Christensen mailto:[EMAIL PROTECTED]
 on Thursday, March 24, 2005 12:34 PM said:
 
  I don't know how to say it any plainer than that.
  
  The original post would have produced the following:
  
  1, 'joe', 'part1'
  1, 'joe', 'part2'
  1, 'joe', 'part3'
  
  but what I'd like to get is:
  1, 'joe', 'part1, part2, part3'
 
 I think this is the explanation we needed.
 
 Serious question: Is it that you want someone to write the loop for your
 do you just need some ideas?
 
  Thanks for your help.  I think I may have to redesign this thing to
  make this easier or I maybe I just don't have the vocabulary to ask
  the question correctly.
 
 A redesign sounds good. Maybe instead of trying to make an oddly
 structured array you can instead adjust the code that receives the array
 to receive the unmodified array?
 
 
 Chris.
 

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



[PHP] Reading from a file using fgets()

2002-08-29 Thread David Christensen

When PHP reads from a file using fgets(), does it do it in order? 
Meaning, when reading STDIN from a file, does it read line1, then line2,
line3, and so on until EOF?

My purpose is to read each line of file and push it into an array.

Thanks for your help,

Dave





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




Re: [PHP] Re: Reading from a file using fgets()

2002-08-29 Thread David Christensen

Interesting.  It's not documented.


On Thu, 2002-08-29 at 14:44, Dallas Thunder wrote:
 Well, this is exactly what function file() does.
 
 David Christensen [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  When PHP reads from a file using fgets(), does it do it in order?
  Meaning, when reading STDIN from a file, does it read line1, then line2,
  line3, and so on until EOF?
 
  My purpose is to read each line of file and push it into an array.
 
  Thanks for your help,
 
  Dave
 
 
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 





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




Re: [PHP] Re: Reading from a file using fgets()

2002-08-29 Thread David Christensen

Ok, file() is docuemted, but it doesn't say anything about whether or
not it reads data sequentially from top to bottom or if there's an
option to read bottom to top or anything in between.

Dave


On Thu, 2002-08-29 at 22:37, @ Edwin wrote:
 Or, is it? :)
 
   http://www.php.net/manual/en/function.file.php
 
 - E
 
 
 Interesting.  It's not documented.
 
 
 On Thu, 2002-08-29 at 14:44, Dallas Thunder wrote:
   Well, this is exactly what function file() does.
  
   David Christensen [EMAIL PROTECTED] wrote in message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
When PHP reads from a file using fgets(), does it do it in order?
Meaning, when reading STDIN from a file, does it read line1, then 
 line2,
line3, and so on until EOF?
   
My purpose is to read each line of file and push it into an array.
   
Thanks for your help,
   
Dave
   
   
   
   
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 _
 最新のファイナンス情報とライフプランのアドバイス MSN 
マネー 
 http://money.msn.co.jp/
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



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




Re: [PHP] Help w/IMAP

2002-08-21 Thread David Christensen

Sorry all, I can't type.  The reference should be imap_header() and
also, here's a snip of the code I'm using:

SNIP

$mbox = imap_open({localhost:143},user,pass)
 or die(can't connect: .imap_last_error());

for($i=1; $i = 5; $i++)
{
$msg_header = imap_header($mbox,$i);
print tr\n;
print td . $i . /td\n;
print td align=right . $msg_header-Size . /td\n;
print td . $msg_header-udate . /td\n;
print td . $msg_header-date . /td\n;
print td . $msg_header-Date . /td\n;
print td . $msg_header-MailDate . /td\n;
print /tr\n;
}

 SNIP


On Wed, 2002-08-21 at 20:42, David Christensen wrote:
 I'm having a weird problem with the certain date fields using the
 imap_head() object in PHP4.  Sorry about the long lines, but I wanted to
 get all the fields for imap_header() in so you could see what I mean.
 
 
 Index Size udate  dateDate   
 MailDate 
 0 2365 1023729291 Fri, 5 Apr 2002 08:30:42 -0800  Fri, 5 Apr 2002 08:30:42 -0800 
 10-Jun-2002 10:14:51 -0700 
 1 1611 1023729291 14 Apr 2002 23:33:02 -  14 Apr 2002 23:33:02 - 
 10-Jun-2002 10:14:51 -0700 
 2 2582 1023729291 Wed, 17 Apr 2002 11:55:26 -0500 Wed, 17 Apr 2002 11:55:26 
-0500 10-Jun-2002 10:14:51 -0700 
 3 1745 1023729291 Thu, 18 Apr 2002 11:43:30 GMT   Thu, 18 Apr 2002 11:43:30 GMT  
 10-Jun-2002 10:14:51 -0700 
 4 2322 1023729290 Wed, 1 May 2002 15:21:02 +1000  Wed, 1 May 2002 15:21:02 +1000 
 10-Jun-2002 10:14:50 -0700 
 
 
 The udate are all the same but one and they don't match what the real date of the 
email head says.  They do however, match the MailDate field.  Here's the phpinfo()
 
 IMAP Supportenabled IMAP c-Client Version4.1
 Apache-AdvancedExtranetServer/1.3.23
 PHP Version 4.1.2
 
 Any help is greatly appreciated!
 
 Dave Christensen
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 




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




[Fwd: Re: [PHP] Dumb question]

2002-08-21 Thread David Christensen





---BeginMessage---

?
function getvar()
{

 $vari = bollocks;  # this $vari is local to function
}

$vari = getvar(); # this $vari is in global space
echo $vari
?

On Wed, 2002-08-21 at 20:35, Bob Irwin wrote:
 You need to declare $vari as a global variable.
 
 
 eg;
 
 ?
 function getvar()
 {
 global $vari;
 
  $vari = bollocks;
 }
  
 getvar();
 echo $vari;
 ?
 
 Best Regards
 Bob Irwin
 Server Admin  Web Programmer
 Planet Netcom
 - Original Message - 
 From: Liam MacKenzie [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, August 22, 2002 1:27 PM
 Subject: [PHP] Dumb question
 
 
  Hey guys, got a basic question for you...
  
  
  
  ?
  function getvar()
  {
   $vari = bollocks;
  }
  
  getvar();
  echo $vari;
  ?
  
  
  How do I make that function return the variable?  
  
  
  Thanks,
  Liam
  
  
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
  Scanned by PeNiCillin http://safe-t-net.pnc.com.au/
  
  Scanned by PeNiCillin http://safe-t-net.pnc.com.au/
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



---End Message---

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