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! 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); ?> 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... 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. 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 ) 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? 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? 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); 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! Link to comment https://forums.phpfreaks.com/topic/230219-explode-on-special-character/#findComment-1185681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.