|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
cutting text in PHP
I am not sure if it is possible in PHP at all.
I have a text field. I copy a block of plain text into it. Now I want a (PHP) code that works this text like this: 1. selects all text UNTIL first comma (,) and stores it to database. 2. then, from the first comma till the second comma, selects all text between these, and stores to DB. 3. and so on. Is it possible in PHP at all, or should I try it in JavaScript or some other language? I am a beginner in PHP ![]() |
|
#2
|
||||
|
||||
|
Head over to php.net and check out the split() function (which is an alias to explode()). These will allow you to split a string on commas and put the values in an array. Then you can put the different array parts into your database.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
thanks, I'll do that. The beginners main problem is, they don't even know what commands to explore
![]() |
|
#4
|
||||
|
||||
|
Yep, I know that conundrum well. When I was first starting out, I wrote all kinds of code to solve problems that there was already a function for. Mosey on over to http://www.php.net/manual/en/ whenever you're in doubt. From there, you can find the reference on string functions, for example, and read a menu of what's at your disposal. It ain't Steinbeck, but if it saves you time and effort in the meantime, it might be worth a few minutes.
|
|
#5
|
|||
|
|||
|
Yea, soon I have visited this page more then any other, but it still remains as a "searching a nail from the beach (or whatever)" style search
![]() Anyway, to everyone like me (beginners, worse case newbies), keep on looking ![]() Thx |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > cutting text in PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|