Kane250 Posted March 10, 2011 Share Posted March 10, 2011 Any way to explode on bullets? I know it's a special character, but I can't figure it out $manyItems = "• the first thing • the second thing • the third thing • etc • etc"; //This doesn't work $items = explode("•", $manyItems); //Neither does this $items = explode("•", $manyItems); Any suggestions? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/ Share on other sites More sharing options...
silkfire Posted March 10, 2011 Share Posted March 10, 2011 It does work mate, you're doing something wrong probably. Try maybe like this: <? $manyItems = '• the first thing • the second thing • the third thing • etc • etc'; //This does work $items = explode(chr(149), $manyItems); print_r($items); ?> Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185611 Share on other sites More sharing options...
Kane250 Posted March 10, 2011 Author Share Posted March 10, 2011 Did you test that? For me it just throws everything into the first array index... Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185656 Share on other sites More sharing options...
HuggieBear Posted March 10, 2011 Share Posted March 10, 2011 The same code works for me too. Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185659 Share on other sites More sharing options...
Kane250 Posted March 10, 2011 Author Share Posted March 10, 2011 I get this output: Items Array ( [0] => � the first thing � the second thing � the third thing � etc � etc ) Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185665 Share on other sites More sharing options...
PFMaBiSmAd Posted March 10, 2011 Share Posted March 10, 2011 Your original data is Unicode/UTF-8 encoded. Do you want it to be that way or can you convert it to ISO-8859-1 which is what the code that works in this thread is using? Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185674 Share on other sites More sharing options...
Kane250 Posted March 10, 2011 Author Share Posted March 10, 2011 Well the website it's being displayed on is in a UTF-8 character set. Is it easy to convert? Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185678 Share on other sites More sharing options...
PFMaBiSmAd Posted March 10, 2011 Share Posted March 10, 2011 In that case, convert the character to match what the data is - $items = explode(utf8_encode('•'), $manyItems); print_r($items); Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185680 Share on other sites More sharing options...
Kane250 Posted March 10, 2011 Author Share Posted March 10, 2011 Ahh, that did the trick! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185681 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.