Re: getting one line of info at a time

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Doug --

...and then Hull, Douglas D said...
% 
% 1. I have a regular html textarea field for a person to enter in words with a carriage return after each word.  In PHP how would I go about getting one line (or word) at a time?  Then I will be needing to get character by character.

You'll get it all because the user will type in as many entries as he
will and then hit the submit button and it all comes to you.

Or were you thinking of some javascript on your page to do things one
word at a time?  [One word about that: YUCK! :-]

If your page looks like

  <form action='/path/to/script.php' method='POST'>
    Type your words:<br>
    <textarea cols='20' rows='4' name='ta'>
    </textarea><br>
    Now type some words here:<br>
    <input type='test' size='20' name='i'><br>
    <input type='submit' value='Click!'>
  </form>

and you feed

  a
  b
  c

and

  a b c

to the fields then your script will have something like

  Array
  (
      [ta] =>     a
  b
  c
      [i] => a b c
  )

for its input.  You can just use a foreach to walk through the list, or
explode based on newlines for multiword input, or whatever you need to do.


HTH & HAND

:-D
-- 
David T-G
davidtg@xxxxxxxxxxxxxxx
http://justpickone.org/davidtg/      Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

Attachment: pgp00098.pgp
Description: PGP signature


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux