CodyBecker Posted January 4, 2010 Share Posted January 4, 2010 Hi all, (Im new to this so go easy on me ) 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. Quote Link to comment https://forums.phpfreaks.com/topic/187087-explode/ Share on other sites More sharing options...
cags Posted January 4, 2010 Share Posted January 4, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/187087-explode/#findComment-988051 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.