Small php question here...
I have a string variable, holding the results from a <textareaof a POSTed
form. I want to create an array from this variable, with each element
containing one line of text from the string.
So, if $myvalue containst
Now is the time
for all good men
to come to the
aid of their country
I end up with this array...
$myvalues[0] = 'Now is the time'
$myvalues[1] = 'for all good men'
$myvalues[2] = 'to come to the'
$myvalues[3] = 'aid of their country'
How can I split this string, at the newlines, into an array? I also don't
want the newlines to be stored in the resulting array.
Thx! 3 2314
"Noozer" <do*******@me.herewrote in message
news:DFnni.128854$1i1.109282@pd7urf3no...
Small php question here...
I have a string variable, holding the results from a <textareaof a
POSTed form. I want to create an array from this variable, with each
element containing one line of text from the string.
So, if $myvalue containst
Now is the time
for all good men
to come to the
aid of their country
I end up with this array...
$myvalues[0] = 'Now is the time'
$myvalues[1] = 'for all good men'
$myvalues[2] = 'to come to the'
$myvalues[3] = 'aid of their country'
How can I split this string, at the newlines, into an array? I also don't
want the newlines to be stored in the resulting array.
Read The Fine Manual:
array explode ( string $delimiter, string $string [, int $limit] )
explode() — Split a string by string http://fi.php.net/manual/en/function.explode.php
-- Ra*********@gmail.com
"Good tea. Nice house." -- Worf
$myvalues = explode("\n",$myline);
Kind regards,
Harrie Verveer
--- http://www.ibuildings.nl/blog/authors/Harrie-Verveer
Noozer wrote:
Small php question here...
I have a string variable, holding the results from a <textareaof a POSTed
form. I want to create an array from this variable, with each element
containing one line of text from the string.
So, if $myvalue containst
Now is the time
for all good men
to come to the
aid of their country
I end up with this array...
$myvalues[0] = 'Now is the time'
$myvalues[1] = 'for all good men'
$myvalues[2] = 'to come to the'
$myvalues[3] = 'aid of their country'
How can I split this string, at the newlines, into an array? I also don't
want the newlines to be stored in the resulting array.
Thx!
Thanks! I was having problems determining what I should use for a delmiter.
"Harrie Verveer"
<ha******************************************@i-buildings.nlwrote in
message news:Mc******************************@zeelandnet.n l...
$myvalues = explode("\n",$myline);
Noozer wrote:
>Small php question here...
I have a string variable, holding the results from a <textareaof a POSTed form. I want to create an array from this variable, with each element containing one line of text from the string.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: stuart |
last post by:
I am posting data to a sql server database via an asp web form. When
retreiving the data the information is all concatenated on one line
i.e.
When posting in textarea the format looks like:
1....
|
by: yezi |
last post by:
Hi:
I want to break a string like "30 23 date" into 3 parts in C:
int 30;
int 23;
char string date;
Do not know how to get it.
|
by: Xiao Jianfeng |
last post by:
Hi,
I need to print a long sting, which is two long so it must expand two
lines.
I know that we can use backslash(\) to explicitly join two lines into a
logical line,
but this doesn't work for...
|
by: rtilley |
last post by:
Hi,
While trying to better understand security descriptors on Windows. I've
been examining text-based security descriptors. I have the security
descriptors on individual lines stored in a text...
|
by: Leonel Gayard |
last post by:
Hi all,
I had to write a small script, and I did it in python instead of
shell-script. My script takes some arguments from the command line,
like this.
import sys
args = sys.argv
if args ==...
|
by: JoeW |
last post by:
Just wondering as I'm sure someone's done something similar to this
before, I need to break up a string, broken up everytime a comma is
come across.
In example:
A, B, C, D, E
This can...
|
by: nashak |
last post by:
Hello,
In a Stored Proc, I am building a string variable. I am getting outputs
from 4 different queries and would like the string to have line breaks
to display each entry in a different line in...
|
by: Auddog |
last post by:
I would like to know how I can break apart a variable. I'm currently
passing the variable $id-hours and I would like to break it down. I would
like to break down to something similar to:
$eid...
|
by: Rob |
last post by:
I am trying to perform client-side input validation for a textarea to
determine that the number of characters doesn't exceed a certain
length. Currently, I am just using str.length, but if the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |