Jump to content

Explode


CodyBecker

Recommended Posts

Hi all,

 

(Im new to this so go easy on me  :shy: )

 

I have a messaging system set up and i want one input field to contain the location to be sent and the message.  So i basically want a text-box that will contain this information in this format.... 

 

[location], [text to send]

 

so . . . . . if i were sending a message to ABC i would type into the text box . . .

 

ABC, Hi how are you

 

So im guessing i would use explode to find the receiver name (ABC) and the message text (Hi how are you) and post them.

Link to comment
https://forums.phpfreaks.com/topic/187087-explode/
Share on other sites

You could use explode for this function but their are several drawbacks. The main one being it will give you problems if you use commas in your message, something which I would have thought you would want to use. The simplest way around that problem is to simply use a less used character such as a colon (:). A more complex solution would be to use either the string functions (such as strpos, substr, strtok etc) to separate the text before the first instance of (,) or to use regular expressions to achieve the same task.

Link to comment
https://forums.phpfreaks.com/topic/187087-explode/#findComment-988051
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.