You are here: Re: Break apart a string at newlines? « PHP Programming Language « IT news, forums, messages
Re: Break apart a string at newlines?

Posted by Rami Elomaa on 07/18/07 12:48

"Noozer" <dont.spam@me.here> wrote in message
news:DFnni.128854$1i1.109282@pd7urf3no...
> Small php question here...
>
> I have a string variable, holding the results from a <textarea> of 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



--
Rami.Elomaa@gmail.com

"Good tea. Nice house." -- Worf

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация