fbemo Posted November 18, 2009 Share Posted November 18, 2009 Hi, I'm trying to create a chatspace inside my web, the code is working just fine but there are slight problems. - When I type :-), it does return a correct value but when I type in >:-), it still will read :-). The result supposedly return an exact value of >:-) not :-). Which this caused the result like this ---> > - Same goes when I type :please... it will return the result like this ---> lease... Question: How to avoid this from reading another value? $aaa[0] = ":-)"; $aaa[1] = ""; $aaa[2] = ":]"; $aaa[3] = "=)"; $aaa[4] = ":-("; $aaa[5] = ""; $aaa[6] = ":["; $aaa[7] = "=("; . . . $aaa[22] = ">:-("; $aaa[23] = ""; $aaa[24] = ":-/"; $aaa[25] = ":/"; $aaa[26] = ":-\\"; $aaa[27] = ":\\"; $aaa[28] = ":'("; $aaa[29] = ""; $aaa[30] = ":*"; $aaa[31] = ""; $aaa[32] = ""; $aaa[33] = "o.O"; $aaa[34] = "O.o"; $aaa[35] = ">-"; $aaa[36] = ">"; $aaa[37] = ">-"; $aaa[38] = ">"; $aaa[39] = ":v"; $aaa[40] = ":3"; $aaa[41] = "8-)"; $aaa[42] = ""; $aaa[43] = "b-)"; $aaa[44] = "b)"; $aaa[45] = "8-|"; $aaa[46] = "8|"; $aaa[47] = "b-|"; $aaa[48] = "b|"; $aaa[49] = "o:-)"; $aaa[50] = "o:)"; $aaa[51] = "3:-)"; $aaa[52] = "3:)"; Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Garethp Posted November 18, 2009 Share Posted November 18, 2009 Well that's obvious, put >:-( before :-( Quote Link to comment Share on other sites More sharing options...
Stephen Posted November 18, 2009 Share Posted November 18, 2009 Place all of the longer strings before the shorter ones in the array. Or: <?php function cmp($a, $b) { return strlen($a)-strlen($b); } $array = array(""); //original array usort($array, "cmp"); $array = array_reverse($array); //new organized array ?> Quote Link to comment Share on other sites More sharing options...
fbemo Posted November 18, 2009 Author Share Posted November 18, 2009 Well that's obvious, put >:-( before :-( There's difference in those, for example typing; >:-) will produce while if typing :-) will produce But my problem is, when people type in >:-) the result print > which obviously I don't want it to be this way. P.s: The emoticons code can't be changed, so I need an alteration with the coding only, thanks again Quote Link to comment Share on other sites More sharing options...
fbemo Posted November 18, 2009 Author Share Posted November 18, 2009 Oh, sorry Garethp, i was misunderstood you. You mean, sort the longest strings before the short ones like Stephen said right? Btw, I think there's still problem, here are the strings >:-( not working perfectly by reading the value of :-( >- not working perfectly by reading the value of :-O O:-) not working perfectly by reading the value of :-) 3:-) not working perfectly by reading the value of :-) o.O not working perfectly (can't read at all) Which 1 should be the first and last? Quote Link to comment Share on other sites More sharing options...
Garethp Posted November 18, 2009 Share Posted November 18, 2009 What do you mean? What I mean, is put >:-( in the array before :-( So $aaa = array( '>:-(', '>:-O', 'O:-)', ':-(', ':-O', ':-)' ); Quote Link to comment Share on other sites More sharing options...
fbemo Posted November 18, 2009 Author Share Posted November 18, 2009 What do you mean? What I mean, is put >:-( in the array before :-( So $aaa = array( '>:-(', '>:-O', 'O:-)', ':-(', ':-O', ':-)' ); Hi, I'm sorry, it's still not working... even tho I've already sorted it... anymore ideas? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 18, 2009 Share Posted November 18, 2009 how are you returning the value ? Quote Link to comment Share on other sites More sharing options...
fbemo Posted November 18, 2009 Author Share Posted November 18, 2009 how are you returning the value ? The value is from user input, it's a chatspace... similar to fb chat. Let say a user type. You can check it at fbemoticons.com, there are 5 strings not working. >:-( not working perfectly by reading the value of :-( >- not working perfectly by reading the value of :-O O:-) not working perfectly by reading the value of :-) 3:-) not working perfectly by reading the value of :-) o.O not working perfectly (can't read at all) Thanks. Quote Link to comment 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.