Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.